Libraries and settings

1. Import and format carbon chemistry data

Seasonality

  • Winter: Jan-Mar
  • Spring: Apr-Jun
  • Summer: Jul-Sep
  • Fall: Oct-Dec
  • Wet: May - October
  • Dry: November - April

2. Check data available

2.1 Locations (all samples)

Figure Supp: Map of the sites where individual samples were collected

Notes: * Check location of individual SiteIDs

2.2 Average GPS point location

Flag samples with coordinates that seem off from the permanent station

# Coordinates<-select(FLK.data, "CTDID", "Latitude", "Longitude", "SiteID")
# Coordinates<-join(Coordinates, WS.GPS.Sites, 
#                  type = "left", by="SiteID")
# Coordinates$Lat_diff <- abs(Coordinates$Latitude-Coordinates$Lat)
# Coordinates$Lon_diff <- abs(Coordinates$Longitude-Coordinates$Lon)
# Check.coordinates1 <- Coordinates[(Coordinates$Lat_diff>0.02), ]
# Check.coordinates2 <- Coordinates[(Coordinates$Lon_diff>0.02), ]
# Check.coordinates <- rbind(Check.coordinates1, Check.coordinates2)
# Check.coordinates <- unique(Check.coordinates)
# #write.csv(Check.coordinates, "FLK_results/2_WrongGPS_points.csv", row.names=F)

- Figure 1: Stations

Figure 1: Location of the permanent sampling stations along the Florida Reef Tract. The black boxes delimitate the biogeographical regions. The color of the stations represents their position along the shelf.

2.3 Number of samples

By zone and location

Sub_region Inshore Mid channel Offshore Oceanic
BB 83 75 82
UK 105 70 110 36
MK 124 126 127 78
LK 133 136 168 85

By year and sub_region

Samples collected each year
Sub_region 2010 2011 2012 2014 2015 2016 2017 2018 2019 2020 2021
BB 4 11 3 6 30 36 30 35 24 24 37
UK 7 15 3 8 45 51 42 44 30 31 45
MK 15 39 9 11 55 66 53 56 43 44 64
LK 18 51 9 11 58 72 59 76 53 45 70

By climatological season and region

Samples collected in each season
Sub_region Fall Spring Winter Summer
LK 149 133 123 117
MK 132 119 95 109
UK 88 81 72 80
BB 68 60 52 60

By Month-year

Samples collected by year-month
2010 2011 2012 2014 2015 2016 2017 2018 2019 2020 2021 Months
38 37 19 6 35 January
16 22 37 February
24 2 38 35 33 March
23 38 15 35 37 April
38 16 28 May
20 24 38 38 35 8 June
37 38 17 36 25 July
19 38 34 10 August
38 38 36 September
28 38 18 38 36 October
37 35 37 November
25 36 37 37 35 December

By Season-year

Samples collected by year-month
2010 2011 2012 2014 2015 2016 2017 2018 2019 2020 2021 Season
24 16 24 76 72 52 6 35 37 Winter
20 47 76 38 38 66 35 73 Spring
75 76 36 38 72 34 35 Summer
53 36 37 35 38 55 37 75 71 Fall

By Month-region

Samples collected by month-location
Sub_region Zone Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
BB Inshore 7 4 7 9 4 8 10 4 6 8 6 10
BB Mid channel 7 3 6 9 4 5 10 4 6 7 6 8
BB Offshore 7 4 7 9 4 8 10 4 6 8 6 9
UK Inshore 10 4 9 13 6 8 13 6 7 9 9 11
UK Mid channel 7 2 7 5 3 9 9 3 6 6 5 8
UK Offshore 12 3 9 11 5 12 14 5 9 11 8 11
UK Oceanic 3 2 4 3 1 5 4 1 3 4 2 4
MK Inshore 9 6 9 12 8 15 12 8 9 13 9 14
MK Mid channel 9 7 11 12 8 13 13 8 9 13 9 14
MK Offshore 10 6 11 13 7 13 13 8 9 13 9 15
MK Oceanic 6 4 7 6 4 8 8 6 6 8 5 10
LK Inshore 11 8 12 12 7 16 9 10 9 15 9 15
LK Mid channel 12 9 12 12 7 15 10 11 9 15 9 15
LK Offshore 18 7 13 14 10 18 13 15 12 19 12 17
LK Oceanic 7 6 8 8 4 10 5 8 6 9 5 9

Per station during all sampling time

Samples collected in SiteIDs
2010 2011 2012 2014 2015 2016 2017 2018 2019 2020 2021 SiteID Sub_region Zone
2 5 1 1 5 6 5 6 4 4 6 1 BB Inshore
2 5 1 1 5 6 5 6 4 4 6 3 BB Offshore
1 3 1 5 6 5 4 2 3 4 4 UK Inshore
1 3 1 1 5 6 5 4 2 3 4 5 UK Inshore
2 2 1 1 5 5 4 4 3 3 4 5.5 UK Mid channel
2 3 1 5 5 4 4 3 3 5 6 UK Offshore
1 4 1 1 5 5 4 4 3 3 5 6.5 UK Oceanic
2 4 1 1 5 6 5 5 4 4 5 10 MK Inshore
1 3 1 1 5 6 5 4 4 4 6 13 MK Inshore
2 5 1 5 6 3 6 4 4 6 7 MK Inshore
2 3 1 1 5 6 5 5 4 4 6 11 MK Mid channel
1 2 1 1 5 6 5 5 4 4 6 14 MK Mid channel
2 4 1 1 5 6 5 6 4 4 6 8 MK Mid channel
1 4 1 1 5 6 5 6 4 4 6 12 MK Offshore
2 5 1 5 6 5 6 4 4 6 9 MK Offshore
2 4 1 1 5 6 5 4 3 4 5 9.5 MK Oceanic
2 5 1 1 5 6 5 6 4 3 5 16 LK Inshore
2 5 1 5 6 4 6 4 4 6 19 LK Inshore
2 5 1 1 5 6 5 7 5 4 6 24 LK Inshore
2 5 1 1 5 6 5 7 4 4 5 17 LK Mid channel
2 5 1 1 5 6 5 6 4 4 6 20 LK Mid channel
1 5 1 1 5 6 5 7 5 4 6 23 LK Mid channel
2 5 1 1 5 6 5 7 4 4 6 18 LK Offshore
1 4 1 5 6 5 5 4 4 6 21LK LK Offshore
1 2 1 1 5 6 5 7 5 4 6 22 LK Offshore
2 5 1 1 4 6 5 5 4 3 6 21.5 LK Oceanic
1 5 1 1 4 6 5 6 5 3 6 22.5 LK Oceanic
1 1 1 5 6 5 6 4 4 6 2 BB Mid channel
3 1 1 5 6 5 5 4 4 6 15 MK Offshore
2 1 1 5 6 5 4 4 4 6 15.5 MK Oceanic
1 5 6 5 6 4 4 7 EK_IN BB Inshore
1 5 6 5 5 4 4 6 EK_MID BB Mid channel
1 5 6 5 6 4 4 6 EK_OFF BB Offshore
1 5 6 5 6 4 4 5 UK_IN UK Inshore
1 5 6 5 5 4 4 6 UK_MID UK Mid channel
1 5 6 5 6 4 4 6 UK_OFF UK Offshore
5 6 5 7 5 4 6 MR UK Offshore
5 6 5 7 5 4 6 WS LK Offshore

Remove extreme events?

# Label and filter extreme events
  FLK.data$Extreme<-as.factor(FLK.data$Extreme)
  summary(FLK.data$Extreme)
## ColdMortality        Low_pH    LowSalinty        Normal 
##            24           109            28          1377
  FLK.data_filtered<-FLK.data[FLK.data$Extreme=="Normal",]

3. TA and DIC salinity normalization

Salinity standardizations

  1. Uses salinity Bottle first, if not available, uses salinity from CTD
#MeanSalinity<-mean(FLK.data[FLK.data$Zone=="Oceanic",]$BestSalinity)
MeanSalinity<-mean(FLK.data$BestSalinity)
sdSalinity<-sd(FLK.data$BestSalinity)

Sal<-paste("Mean salinity = ", round(MeanSalinity, digits=3),
           "(", round(sdSalinity, digits=3), "sd)")
Sal
## [1] "Mean salinity =  35.998 ( 0.796 sd)"
TA_Sal<- ggplot(FLK.data) + MyTheme+
  geom_point(aes (BestSalinity, TA_umol_kg, fill=Season),
             alpha=0.5, shape=21, size=1)+
  geom_smooth(aes(BestSalinity, TA_umol_kg),
              linetype=2, method = "lm", color="black")

ggExtra::ggMarginal(
  p = TA_Sal,
  type = 'boxplot',
  margins = 'both',
  size = 5,
  colour = 'black',
  fill = 'gray'
)

TA_Sal + facet_wrap(~Zone)

TA_Sal+ facet_grid(Zone~Season)
#TA_Sal+ facet_grid(Zone~Precipitation)

DIC_Sal<- ggplot(FLK.data) + MyTheme+
  geom_point(aes (BestSalinity, DIC_umol_kg, fill=Season),
             alpha=0.5, shape=21, size=1)+
  geom_smooth(aes(BestSalinity, DIC_umol_kg),
              linetype=2, method = "lm", color="black")

ggExtra::ggMarginal(
  p = DIC_Sal,
  type = 'boxplot',
  margins = 'both',
  size = 5,
  colour = 'black',
  fill = 'gray'
)

DIC_Sal + facet_wrap(~Zone)

DIC_Sal+ facet_grid(Zone~Season)

  1. Calculate TA intercepts

Note: Use Model II Linear regressions!

“For Model II regressions, neither X nor Y is an INDEPENDENT variable but both are assumed to be DEPENDENT on some other parameter which is often unknown. Neither are”controlled”, both are measured, and both include some error. We do not seek an equation of how Y varies in response to a change in X, but rather we look for how they both co-vary in time or space in response to some other variable or process.”

  • Use ordinary least squares (OLS)?

All data

## 
## Model II regression
## 
## Call: lmodel2(formula = TA_umol_kg ~ BestSalinity, data =
## FLK.data_filtered)
## 
## n = 1374   r = -0.2278987   r-square = 0.05193781 
## Parametric P-values:   2-tailed = 1.202032e-17    1-tailed = 6.010158e-18 
## Angle between the two OLS regression lines = 2.667424 degrees
## 
## Regression results
##   Method Intercept      Slope Angle (degrees) P-perm (1-tailed)
## 1    OLS  3097.785  -20.34694       -87.18632                NA
## 2     MA 16500.250 -391.70923       -89.85373                NA
## 3    SMA  5585.602  -89.28064       -89.35828                NA
## 
## Confidence intervals
##   Method 2.5%-Intercept 97.5%-Intercept 2.5%-Slope 97.5%-Slope
## 1    OLS       2931.598        3263.973  -24.95088   -15.74300
## 2     MA      13891.723       20634.460 -506.26203  -319.43084
## 3    SMA       5423.727        5756.040  -94.00321   -84.79532
## 
## Eigenvalues: 3868.259 0.4600788 
## 
## H statistic used for computing C.I. of MA: 3.336788e-07

Oceanic

## 
## Model II regression
## 
## Call: lmodel2(formula = TA_umol_kg ~ BestSalinity, data =
## FLK.data_filtered[FLK.data_filtered$Zone == "Oceanic", ])
## 
## n = 176   r = 0.3257975   r-square = 0.106144 
## Parametric P-values:   2-tailed = 1.022381e-05    1-tailed = 5.111904e-06 
## Angle between the two OLS regression lines = 7.094668 degrees
## 
## Regression results
##   Method  Intercept     Slope Angle (degrees) P-perm (1-tailed)
## 1    OLS 2122.28183  7.166943        82.05683                NA
## 2     MA  -48.06268 67.396258        89.14993                NA
## 3    SMA 1587.84376 21.998155        87.39722                NA
## 
## Confidence intervals
##   Method 2.5%-Intercept 97.5%-Intercept 2.5%-Slope 97.5%-Slope
## 1    OLS       2010.133       2234.4303    4.05505    10.27884
## 2     MA      -1911.555        687.2507   46.99055   119.11010
## 3    SMA       1467.815       1692.0877   19.10528    25.32906
## 
## Eigenvalues: 139.7934 0.2581017 
## 
## H statistic used for computing C.I. of MA: 4.148763e-05

  1. Calculate DIC intercepts

All data

## 
## Model II regression
## 
## Call: lmodel2(formula = DIC_umol_kg ~ BestSalinity, data =
## FLK.data_filtered)
## 
## n = 1367   r = -0.3836313   r-square = 0.1471729 
## Parametric P-values:   2-tailed = 3.640591e-49    1-tailed = 1.820295e-49 
## Angle between the two OLS regression lines = 1.280546 degrees
## 
## Regression results
##   Method Intercept      Slope Angle (degrees) P-perm (1-tailed)
## 1    OLS  3409.339  -38.14802       -88.49841                NA
## 2     MA 11386.282 -259.18306       -89.77894                NA
## 3    SMA  5621.283  -99.43930       -89.42383                NA
## 
## Confidence intervals
##   Method 2.5%-Intercept 97.5%-Intercept 2.5%-Slope 97.5%-Slope
## 1    OLS       3233.340        3585.339  -43.02393   -33.27211
## 2     MA      10326.227       12757.025 -297.16533  -229.80975
## 3    SMA       5449.627        5801.561 -104.43468   -94.68286
## 
## Eigenvalues: 4816.519 0.4153987 
## 
## H statistic used for computing C.I. of MA: 2.431873e-07

Oceanic

## 
## Model II regression
## 
## Call: lmodel2(formula = DIC_umol_kg ~ BestSalinity, data =
## FLK.data_filtered[FLK.data_filtered$Zone == "Oceanic", ])
## 
## n = 174   r = 0.3149479   r-square = 0.09919215 
## Parametric P-values:   2-tailed = 2.308735e-05    1-tailed = 1.154368e-05 
## Angle between the two OLS regression lines = 4.949134 degrees
## 
## Regression results
##   Method  Intercept     Slope Angle (degrees) P-perm (1-tailed)
## 1    OLS  1669.8245  10.39310        84.50405                NA
## 2     MA -1728.0070 104.69073        89.45273                NA
## 3    SMA   855.2498  32.99942        88.26426                NA
## 
## Confidence intervals
##   Method 2.5%-Intercept 97.5%-Intercept 2.5%-Slope 97.5%-Slope
## 1    OLS      1499.9523        1839.697   5.679278    15.10691
## 2     MA     -4858.8657        -550.885  72.022893   191.57926
## 3    SMA       673.3265        1013.033  28.620573    38.04821
## 
## Eigenvalues: 317.9112 0.2629337 
## 
## H statistic used for computing C.I. of MA: 1.876549e-05

  1. Add TA and DIC endmembers (S=0) to data frame
# 4. Add endmember intercepts

  TA_SO<-subset(TA_coef, term=="(Intercept)")
  TA_SO<-as.data.frame(dplyr::select(TA_SO, c(Region, estimate)))
  names(TA_SO)[2] <- "TA_0"
  
  DIC_SO<-subset(DIC_coef, term=="(Intercept)")
  DIC_SO<-as.data.frame(dplyr::select(DIC_SO, c(Region, estimate)))
  names(DIC_SO)[2] <- "DIC_0"
    
  Intercepts<-join(TA_SO, DIC_SO, by="Region", type="full")
  FLK.data<-join(FLK.data, Intercepts, by="Region", type="left")
  1. Normalize with (1) Friss equation and (2) mean salinity
  # 5. endmember and salinity (mean) normalization
  FLK.data$nTA<-((
    (FLK.data$TA_umol_kg-FLK.data$TA_0)/
    FLK.data$BestSalinity)*MeanSalinity)+FLK.data$TA_0
  
  FLK.data$nDIC<-((
    (FLK.data$DIC_umol_kg-FLK.data$DIC_0)/
    FLK.data$BestSalinity)*MeanSalinity)+FLK.data$DIC_0
  
  # 2. TA and DIC 35 normalization
    FLK.data$n35TA<-(FLK.data$TA_umol_kg/FLK.data$BestSalinity)*MeanSalinity
    FLK.data$n35DIC<-(FLK.data$DIC_umol_kg/FLK.data$BestSalinity)*MeanSalinity
    # FLK.data$n35TA<-(FLK.data$TA_umol_kg/FLK.data$BestSalinity)*35
    # FLK.data$n35DIC<-(FLK.data$DIC_umol_kg/FLK.data$BestSalinity)*35
  
#write.csv(FLK.data, "FLK_results/FLK.data_filtered_normalized.csv", row.names = F)
  1. TA parameters to nTA (S=0)
kable(as.data.frame(TA_coef[,1:8], format = "markdown"), 
      caption = "Table 1: TA parameters for salinity normalization with endmember S=0",
      digits = 3)%>% 
kable_styling(bootstrap_options = c("striped", "condensed", full_width = F), font_size = 11)
Table 1: TA parameters for salinity normalization with endmember S=0
Region term estimate std.error statistic p.value r.squared adj.r.squared
FL (Intercept) 2122.282 56.822 37.350 0 0.106 0.101
FL BestSalinity 7.167 1.577 4.546 0 0.106 0.101
#write.csv(TA_coef, "TA_coef.csv")
# Plot 
Normalization_plot<- ggplot(FLK.data) +
  theme_bw() +  
  theme(legend.position="bottom",
          plot.background=element_blank(),
          panel.grid.major.y = element_blank(),
          panel.grid.major.x = element_blank(),
          panel.grid.minor.x = element_blank(),
          panel.grid.minor.y = element_blank(),
          legend.box.background = element_rect(),
          legend.title = element_blank(),
          panel.background =element_rect(fill = NA, 
                                         color = "black"))+
         scale_x_continuous(limits = c(31.5, 39),
                     expand = c(0.05, 0.05),
                     breaks = seq(30, 40, 2),
                     name=expression(paste("Salinity")))
  1. DIC parameters to nDIC (S=0)
kable(as.data.frame(DIC_coef[,1:8], format = "markdown"), 
      caption = "Table 2: DIC parameters for salinity normalization with endmember S0",
      digits = 2) %>% 
kable_styling(bootstrap_options = c("striped", "condensed", full_width = F), font_size = 11)
Table 2: DIC parameters for salinity normalization with endmember S0
Region term estimate std.error statistic p.value r.squared adj.r.squared
FL (Intercept) 1669.82 86.06 19.40 0 0.1 0.09
FL BestSalinity 10.39 2.39 4.35 0 0.1 0.09
#write.csv(DIC_coef, "DIC_coef.csv")

Figure Supp 1: Overview of linear regressions of total alkalinity (TA, µmol kg−1) and dissolved inorganic carbon (DIC, µmol kg−1) as a function of salinity + Friss normalized values.

  • Original data: Black line and circles
  • Friis normalization S0 end-member: purple line and pointing up triangles
  • Mean salinity normalization: purple line and pointing down triangles

TA vs Friss salinity normalized TA

Figure Supp X: Linear regressions of Friss normalized total alkalinity (nTA, µmol kg−1) as a function of measured Total Alcalinity (TA, µmol kg−1)

DIC vs Friss salinity normalized DIC

Figure Supp X: Linear regressions of Friss normalized Dissolved Inorganc Carbon (nDIC, µmol kg−1) as a function of measured Dissolved Inorganc Carbon (DIC, µmol kg−1)

TA vs Salinity normalized TA

Figure Supp X: Linear regressions of mean salinity normalized total alkalinity (n35TA, µmol kg−1) as a function of measured Total Alcalinity (TA, µmol kg−1)

DIC vs Salinity normalized DIC

Figure Supp X: Linear regressions of mean salinity normalized Dissolved Inorganc Carbon (n35DIC, µmol kg−1) as a function of measured Dissolved Inorganc Carbon (DIC, µmol kg−1)

Differences vs Salinity

Figure Supp X: Linear regressions of (A) TA-n35TA and (B) DIC-nDIC as a function of Salinity

4. Endmember comparissions

FLK.data_filtered<-FLK.data[FLK.data$Extreme=="Normal",]

4.1 TA and DIC relation

No_ocean.data<-FLK.data[FLK.data$Zone!="Oceanic",]

TA_DIC<- ggplot(No_ocean.data, aes (DIC_umol_kg, TA_umol_kg)) +

  scale_y_continuous(#limits = c(1700,2900),
                     #expand = c(0, 0),
                     #breaks = seq(1800, 2800, 100),
                     expression(paste("TA (", mu, "mol ", kg^-1, ")")))+
  scale_x_continuous(# limits = c(1600, 2600),
                     # expand = c(0, 0),
                     # breaks = seq(1500,2600,100),
                     expression(paste("DIC (", mu, "mol ", kg^-1, ")")))+
  facet_grid(Sub_region~Zone)+ MyTheme+ 
  theme(legend.position = "bottom")+
  #Season_fill+ Season_colour+
  guides(fill=guide_legend(override.aes=list(shape=21)))
TA_DIC_Zone <- ddply (FLK.data[FLK.data$Extreme=="Normal", ], .(Zone),summarise,
                TAmean = mean (TA_umol_kg, na.rm = T), 
                DICmean = mean (DIC_umol_kg, na.rm = T),
                nTAmean = mean (n35TA, na.rm = T), 
                nDICmean = mean (n35DIC, na.rm = T),
                TAsd = sd (TA_umol_kg, na.rm = T), 
                DICsd = sd (DIC_umol_kg, na.rm = T),
                nTAsd = sd (n35TA, na.rm = T), 
                nDIsd = sd (n35DIC, na.rm = T))

TA_DIC_Ocean<-TA_DIC_Zone[TA_DIC_Zone$Zone=="Oceanic", ]

kable(as.data.frame(TA_DIC_Zone, format = "markdown"),
      caption = "Mean TA/DIC by zone") %>% 
kable_styling(bootstrap_options = c("striped", "condensed", full_width = F), font_size = 11)
Mean TA/DIC by zone
Zone TAmean DICmean nTAmean nDICmean TAsd DICsd nTAsd nDIsd
Inshore 2340.787 2015.064 2333.990 2010.188 97.58327 110.70733 134.66366 147.79067
Mid channel 2364.723 2032.800 2359.007 2028.192 52.41657 58.19787 65.92103 74.37988
Offshore 2376.329 2043.844 2372.737 2040.658 19.67731 23.76709 37.86618 36.47511
Oceanic 2380.540 2044.319 2378.570 2042.690 11.82213 17.82925 34.44739 30.81862

Note: Use Model II Linear regressions!

“For Model II regressions, neither X nor Y is an INDEPENDENT variable but both are assumed to be DEPENDENT on some other parameter which is often unknown. Neither are”controlled”, both are measured, and both include some error. We do not seek an equation of how Y varies in response to a change in X, but rather we look for how they both co-vary in time or space in response to some other variable or process.”

Zone and region

# Individual LR for each Zone and Sub_region
    
TA_DIC_coef_zone_noExtremes <- No_ocean.data[No_ocean.data$Extreme=="Normal", ] %>% 
                    group_by(Zone, Sub_region) %>%
                    do({model = lm(TA_umol_kg~DIC_umol_kg, data=.)  
                    # create model
                    data.frame(tidy(model), # get coefficient info
                    glance(model))})        # get model info

TA_DIC_coef_zone_noExtremes<-subset(TA_DIC_coef_zone_noExtremes, term!="(Intercept)")
kable(as.data.frame(TA_DIC_coef_zone_noExtremes[,1:8], 
      format = "markdown"),
      caption = "TA vs DIC equations by zone and region without extreme events",
      digits = 2)%>% 
kable_styling(bootstrap_options = c("striped", "condensed", full_width = F), font_size = 11)
TA vs DIC equations by zone and region without extreme events
Zone Sub_region term estimate std.error statistic p.value r.squared
Inshore BB DIC_umol_kg 0.67 0.04 15.22 0 0.76
Inshore UK DIC_umol_kg 0.58 0.03 18.50 0 0.78
Inshore MK DIC_umol_kg 0.81 0.04 22.42 0 0.82
Inshore LK DIC_umol_kg 0.86 0.04 21.38 0 0.80
Mid channel BB DIC_umol_kg 0.57 0.06 9.71 0 0.58
Mid channel UK DIC_umol_kg 0.41 0.07 6.16 0 0.38
Mid channel MK DIC_umol_kg 0.83 0.04 21.55 0 0.81
Mid channel LK DIC_umol_kg 0.81 0.04 20.72 0 0.79
Offshore BB DIC_umol_kg 0.58 0.09 6.70 0 0.38
Offshore UK DIC_umol_kg 0.57 0.05 10.84 0 0.55
Offshore MK DIC_umol_kg 0.77 0.04 19.96 0 0.78
Offshore LK DIC_umol_kg 0.57 0.04 13.61 0 0.56
#write.csv(TA_DIC_coef_zone_noExtremes, "FLK_results/Fig_2_TA_DIC_coef_slopes_Subregion.csv", row.names = FALSE)

# Annotations for plots
  coef_zone_noExtremes<-dplyr::select(TA_DIC_coef_zone_noExtremes, 
                               c("Zone", "Sub_region", "estimate", "r.squared"))
  coef_zone_noExtremes$estimate<-round(coef_zone_noExtremes$estimate, digits=2)
  coef_zone_noExtremes$r.squared<-round(coef_zone_noExtremes$r.squared, digits=2)

Type II Linear regression

TA_DIC_coef_zone_noExtII <- No_ocean.data[No_ocean.data$Extreme=="Normal", ] %>% 
                    group_by(Zone, Sub_region) %>%
                    do({model = lmodel2(TA_umol_kg~DIC_umol_kg, data=.)  
                    # create model
                    data.frame(tidy(model), # get coefficient info
                    glance(model))})        # get model info
#TA_DIC_coef_zone_noExtII

TA_DIC_coef_zone_noExtII<-subset(TA_DIC_coef_zone_noExtII, term!="Intercept")
kable(as.data.frame(TA_DIC_coef_zone_noExtII[,1:9], 
      format = "markdown"),
      caption = "TA vs DIC equations without extreme events using type II lm",
      digits = 2)%>% 
kable_styling(bootstrap_options = c("striped", "condensed", full_width = F), font_size = 11)
TA vs DIC equations without extreme events using type II lm
Zone Sub_region method term estimate conf.low conf.high p.value r.squared
Inshore BB MA Slope 0.74 0.64 0.84 0.76
Inshore BB OLS Slope 0.67 0.58 0.76 0.76
Inshore BB SMA Slope 0.77 0.68 0.86 0.76
Inshore UK MA Slope 0.62 0.56 0.69 0.78
Inshore UK OLS Slope 0.58 0.52 0.64 0.78
Inshore UK SMA Slope 0.66 0.60 0.72 0.78
Inshore MK MA Slope 0.89 0.81 0.97 0.82
Inshore MK OLS Slope 0.81 0.74 0.88 0.82
Inshore MK SMA Slope 0.90 0.83 0.97 0.82
Inshore LK MA Slope 0.96 0.87 1.05 0.80
Inshore LK OLS Slope 0.86 0.78 0.94 0.80
Inshore LK SMA Slope 0.96 0.89 1.05 0.80
Mid channel BB MA Slope 0.69 0.55 0.84 0.58
Mid channel BB OLS Slope 0.57 0.45 0.69 0.58
Mid channel BB SMA Slope 0.75 0.64 0.87 0.58
Mid channel UK MA Slope 0.54 0.37 0.73 0.38
Mid channel UK OLS Slope 0.41 0.28 0.55 0.38
Mid channel UK SMA Slope 0.67 0.55 0.82 0.38
Mid channel MK MA Slope 0.91 0.83 1.00 0.81
Mid channel MK OLS Slope 0.83 0.75 0.90 0.81
Mid channel MK SMA Slope 0.92 0.85 1.00 0.81
Mid channel LK MA Slope 0.90 0.82 0.99 0.79
Mid channel LK OLS Slope 0.81 0.73 0.88 0.79
Mid channel LK SMA Slope 0.91 0.84 0.99 0.79
Offshore BB MA Slope 0.89 0.65 1.20 0.38
Offshore BB OLS Slope 0.58 0.40 0.75 0.38
Offshore BB SMA Slope 0.93 0.77 1.12 0.38
Offshore UK MA Slope 0.70 0.58 0.84 0.55
Offshore UK OLS Slope 0.57 0.47 0.67 0.55
Offshore UK SMA Slope 0.77 0.67 0.88 0.55
Offshore MK MA Slope 0.86 0.78 0.95 0.78
Offshore MK OLS Slope 0.77 0.70 0.85 0.78
Offshore MK SMA Slope 0.87 0.80 0.95 0.78
Offshore LK MA Slope 0.70 0.60 0.80 0.56
Offshore LK OLS Slope 0.57 0.49 0.65 0.56
Offshore LK SMA Slope 0.76 0.68 0.85 0.56
# Annotations for plots
  TA_DIC_coef_zone_noExtII<-dplyr::select(TA_DIC_coef_zone_noExtII, 
                               c("Zone", "Sub_region","method", "estimate", "r.squared"))
  TA_DIC_coef_zone_noExtII$estimate<-round(TA_DIC_coef_zone_noExtII$estimate, digits=2)
  TA_DIC_coef_zone_noExtII$r.squared<-round(TA_DIC_coef_zone_noExtII$r.squared, digits=2)

4.2 By Precipitation - Removing Extreme events

TA_DIC_Extreme_pre<-TA_DIC + 
  geom_abline(intercept = -1700, slope=2, color="grey")+
  geom_hline (yintercept = TA_DIC_Ocean$TAmean, color="grey")+
  scale_shape_manual(values=c(24, 25, 23, 22, 21))+
  geom_point(data=No_ocean.data, aes (DIC_umol_kg, TA_umol_kg,
                                 fill=Precipitation, shape=Extreme),
                            alpha=0.5, size=1)+
  geom_smooth(data=No_ocean.data[No_ocean.data$Extreme=="Normal", ], 
              aes(DIC_umol_kg, TA_umol_kg), 
              method = "lm", colour="black", se=F)+
  
   geom_smooth(data=No_ocean.data[No_ocean.data$Extreme=="Normal", ], 
              aes(DIC_umol_kg, TA_umol_kg, colour=Precipitation), 
              method = "lm", se=F, size=0.5)+
  
  geom_text(data = coef_zone_noExtremes, 
            aes(x = TA_DIC_Ocean$DICmean, y = 2070,
                label = paste("Slo =", estimate,  
                              " r.sq=", r.squared)),
            size=2.5)+
  
  # geom_abline(slope = 0, intercept =TA_DIC_Ocean$TAmean, 
  #           linetype=2, colour="gray")+
  # geom_vline(xintercept = TA_DIC_Ocean$DICmean,
  #          linetype=2, colour="gray")+
  geom_point(aes(x=TA_DIC_Ocean$DICmean, y=TA_DIC_Ocean$TAmean),
             size=3, alpha=1, shape=21, fill="black")
#TA_DIC_Extreme_pre

Zone, region and transect

TA_DIC_reef_pre<-TA_DIC_Extreme_pre + 
  facet_grid(Zone~Reference)
#TA_DIC_reef_pre
# Individual LR for each reef
TA_DIC_coef_Reef_noExtremes <- No_ocean.data[No_ocean.data$Extreme=="Normal", ] %>% 
            group_by(Zone, Sub_region, Reference, Precipitation) %>%
            do({model = lm(TA_umol_kg~DIC_umol_kg, data=.)  
                    # create model
            data.frame(tidy(model), # get coefficient info
            glance(model))})        # get model info

TA_DIC_coef_Reef_noExtremes<-subset(TA_DIC_coef_Reef_noExtremes, term!="(Intercept)")
kable(as.data.frame(TA_DIC_coef_Reef_noExtremes[,1:11],
                      format = "markdown"),
        caption = "TA vs DIC equations by reef without extreme events per trsansec",
        digits = 2)%>% 
kable_styling(bootstrap_options = c("striped", "condensed", full_width = F), font_size = 11)
TA vs DIC equations by reef without extreme events per trsansec
Zone Sub_region Reference Precipitation term estimate std.error statistic p.value r.squared adj.r.squared
Inshore BB BB_1 Dry DIC_umol_kg 0.58 0.05 10.57 0.00 0.85 0.85
Inshore BB BB_1 Wet DIC_umol_kg 0.72 0.07 10.43 0.00 0.86 0.86
Inshore BB BB_2 Dry DIC_umol_kg 0.54 0.07 7.89 0.00 0.79 0.77
Inshore BB BB_2 Wet DIC_umol_kg 0.47 0.15 3.15 0.01 0.42 0.37
Inshore UK UK_3 Dry DIC_umol_kg 0.58 0.03 18.79 0.00 0.92 0.91
Inshore UK UK_3 Wet DIC_umol_kg 0.47 0.09 5.16 0.00 0.50 0.48
Inshore UK UK_4 Dry DIC_umol_kg 0.54 0.05 11.46 0.00 0.90 0.89
Inshore UK UK_4 Wet DIC_umol_kg 0.35 0.22 1.59 0.13 0.15 0.09
Inshore MK MK_5 Dry DIC_umol_kg 0.56 0.06 8.81 0.00 0.82 0.81
Inshore MK MK_5 Wet DIC_umol_kg 0.70 0.11 6.19 0.00 0.71 0.69
Inshore MK MK_6 Dry DIC_umol_kg 0.72 0.09 8.38 0.00 0.81 0.80
Inshore MK MK_6 Wet DIC_umol_kg 0.80 0.13 6.25 0.00 0.70 0.68
Inshore MK MK_7 Dry DIC_umol_kg 0.67 0.08 8.84 0.00 0.84 0.83
Inshore MK MK_7 Wet DIC_umol_kg 0.93 0.15 6.18 0.00 0.69 0.67
Inshore LK LK_8 Dry DIC_umol_kg 0.79 0.10 8.00 0.00 0.78 0.77
Inshore LK LK_8 Wet DIC_umol_kg 0.80 0.11 7.18 0.00 0.76 0.75
Inshore LK LK_9 Dry DIC_umol_kg 0.68 0.09 7.62 0.00 0.77 0.76
Inshore LK LK_9 Wet DIC_umol_kg 0.70 0.19 3.76 0.00 0.47 0.44
Inshore LK LK_10 Dry DIC_umol_kg 0.84 0.14 5.87 0.00 0.63 0.61
Inshore LK LK_10 Wet DIC_umol_kg 0.64 0.14 4.74 0.00 0.57 0.54
Mid channel BB BB_1 Dry DIC_umol_kg 0.53 0.08 6.67 0.00 0.72 0.71
Mid channel BB BB_1 Wet DIC_umol_kg 0.60 0.14 4.36 0.00 0.56 0.53
Mid channel BB BB_2 Dry DIC_umol_kg 0.52 0.09 5.54 0.00 0.66 0.64
Mid channel BB BB_2 Wet DIC_umol_kg 0.38 0.29 1.30 0.22 0.12 0.05
Mid channel UK UK_3 Dry DIC_umol_kg 0.36 0.14 2.58 0.02 0.36 0.30
Mid channel UK UK_3 Wet DIC_umol_kg 0.00 0.17 -0.02 0.98 0.00 -0.07
Mid channel UK UK_4 Dry DIC_umol_kg 0.49 0.10 4.77 0.00 0.60 0.58
Mid channel UK UK_4 Wet DIC_umol_kg 0.63 0.25 2.57 0.02 0.32 0.27
Mid channel MK MK_5 Dry DIC_umol_kg 0.47 0.10 4.53 0.00 0.53 0.51
Mid channel MK MK_5 Wet DIC_umol_kg 0.88 0.17 5.18 0.00 0.61 0.59
Mid channel MK MK_6 Dry DIC_umol_kg 0.59 0.09 6.35 0.00 0.70 0.69
Mid channel MK MK_6 Wet DIC_umol_kg 0.83 0.10 8.45 0.00 0.82 0.81
Mid channel MK MK_7 Dry DIC_umol_kg 0.63 0.07 8.50 0.00 0.82 0.81
Mid channel MK MK_7 Wet DIC_umol_kg 1.09 0.12 9.25 0.00 0.84 0.83
Mid channel LK LK_8 Dry DIC_umol_kg 0.56 0.16 3.50 0.00 0.39 0.36
Mid channel LK LK_8 Wet DIC_umol_kg 0.96 0.07 14.05 0.00 0.92 0.92
Mid channel LK LK_9 Dry DIC_umol_kg 0.67 0.10 6.51 0.00 0.70 0.69
Mid channel LK LK_9 Wet DIC_umol_kg 0.92 0.12 7.51 0.00 0.77 0.75
Mid channel LK LK_10 Dry DIC_umol_kg 0.42 0.18 2.37 0.03 0.22 0.18
Mid channel LK LK_10 Wet DIC_umol_kg 0.88 0.13 6.51 0.00 0.73 0.71
Offshore BB BB_1 Dry DIC_umol_kg 0.53 0.11 4.70 0.00 0.54 0.51
Offshore BB BB_1 Wet DIC_umol_kg 0.61 0.22 2.82 0.01 0.32 0.28
Offshore BB BB_2 Dry DIC_umol_kg 0.49 0.15 3.28 0.00 0.40 0.37
Offshore BB BB_2 Wet DIC_umol_kg 0.57 0.31 1.82 0.09 0.19 0.13
Offshore UK UK_3 Dry DIC_umol_kg 0.63 0.10 6.55 0.00 0.60 0.58
Offshore UK UK_3 Wet DIC_umol_kg 0.56 0.15 3.82 0.00 0.32 0.30
Offshore UK UK_4 Dry DIC_umol_kg 0.48 0.09 5.19 0.00 0.63 0.60
Offshore UK UK_4 Wet DIC_umol_kg 0.90 0.13 6.90 0.00 0.77 0.76
Offshore MK MK_5 Dry DIC_umol_kg 0.50 0.10 5.09 0.00 0.59 0.57
Offshore MK MK_5 Wet DIC_umol_kg 0.85 0.07 12.02 0.00 0.89 0.89
Offshore MK MK_6 Dry DIC_umol_kg 0.51 0.10 4.89 0.00 0.56 0.53
Offshore MK MK_6 Wet DIC_umol_kg 1.07 0.11 9.62 0.00 0.86 0.85
Offshore MK MK_7 Dry DIC_umol_kg 0.43 0.09 4.67 0.00 0.58 0.55
Offshore MK MK_7 Wet DIC_umol_kg 0.95 0.10 9.22 0.00 0.84 0.83
Offshore LK LK_8 Dry DIC_umol_kg 0.25 0.08 3.09 0.01 0.35 0.31
Offshore LK LK_8 Wet DIC_umol_kg 0.97 0.11 8.46 0.00 0.80 0.79
Offshore LK LK_9 Dry DIC_umol_kg 0.55 0.09 6.41 0.00 0.73 0.71
Offshore LK LK_9 Wet DIC_umol_kg 0.83 0.12 6.98 0.00 0.75 0.74
Offshore LK LK_10 Dry DIC_umol_kg 0.48 0.10 4.91 0.00 0.41 0.40
Offshore LK LK_10 Wet DIC_umol_kg 0.77 0.13 5.72 0.00 0.50 0.48
#write.csv (TA_DIC_coef_Reef_noExtremes, "FLK_results/Fig_2_TA_DIC_slopes_Reefs.csv", row.names = FALSE)
  
  
TA_DIC_coef_Reef_noExtremes <- 
  No_ocean.data[No_ocean.data$Extreme=="Normal", ] %>% 
                    group_by(Zone, Region, Sub_region, Transect, Precipitation) %>%
                    do({model = lm(TA_umol_kg~DIC_umol_kg, data=.)  
                    # create model
                    data.frame(tidy(model), # get coefficient info
                    glance(model))})        # get model info
Slopes_reef<-subset(TA_DIC_coef_Reef_noExtremes, term!="(Intercept)")

Slope_plot<-ggplot(data=Slopes_reef, aes (x =Zone, y =estimate)) +
  MyTheme+
  scale_shape_manual(values=c(24, 25, 23, 22, 21))+
  geom_boxplot(aes(fill=(Precipitation)), alpha=0.5,
               position=position_dodge(width=0.3))+
  geom_point(aes(fill = factor(Precipitation)), 
              position=position_dodge(width=0.3),
             shape = 21, size=0.5)+
  scale_y_continuous(#limits = c(1700,2900),
                     #expand = c(0, 0),
                     #breaks = seq(1800, 2800, 100),
                     expression(paste("TA vs DIC slope")))+
  theme(axis.text.x = element_text(angle = 0, vjust = 0.1),
        legend.position = "bottom")+
  #guides(fill=FALSE)+
  facet_grid(Sub_region~Region)
  # Season_fill+ Season_colour+
  # theme(legend.title = element_blank())
#Slope_plot

Figure S9: TA (µmol kg−1) vs DIC (µmol kg−1) slopes per season and reef

4.3 By Season - Removing Extreme events

TA_DIC_season<-TA_DIC + 
  Season_colour+ Season_fill+
  geom_abline(intercept = -1700, slope=2, color="grey")+
  geom_hline (yintercept = TA_DIC_Ocean$TAmean, color="grey")+
  scale_shape_manual(values=c(24, 25, 23, 22, 21))+
  geom_point(data=No_ocean.data, aes (DIC_umol_kg, TA_umol_kg,
                                 fill=Season, shape=Extreme),
                            alpha=0.5, size=1)+
  geom_smooth(data=No_ocean.data[No_ocean.data$Extreme=="Normal", ], 
              aes(DIC_umol_kg, TA_umol_kg), 
              method = "lm", colour="black", se=F)+
  
   geom_smooth(data=No_ocean.data[No_ocean.data$Extreme=="Normal", ], 
              aes(DIC_umol_kg, TA_umol_kg, colour=Season), 
              method = "lm", se=F, size=0.5)+
  
  geom_text(data = coef_zone_noExtremes, 
            aes(x = TA_DIC_Ocean$DICmean, y = 2070,
                label = paste("Slo =", estimate,  
                              " r.sq=", r.squared)),
            size=2.5)+

  geom_point(aes(x=TA_DIC_Ocean$DICmean, y=TA_DIC_Ocean$TAmean),
             size=3, alpha=1, shape=21, fill="black")
#TA_DIC_season
# Individual LR for each reef
TA_DIC_coef_Season_noExtremes <- FLK.data[FLK.data$Extreme=="Normal", ] %>% 
                    group_by(Zone, Sub_region, Season) %>%
                    do({model = lm(TA_umol_kg~DIC_umol_kg, data=.)  
                    # create model
                    data.frame(tidy(model), # get coefficient info
                    glance(model))})        # get model info

TA_DIC_coef_Season_noExtremes<-subset(TA_DIC_coef_Season_noExtremes, term!="(Intercept)")
kable(as.data.frame(TA_DIC_coef_Season_noExtremes[,1:11],
                      format = "markdown"),
        caption = "TA vs DIC equations by season without extreme events",
        digits = 2)%>% 
kable_styling(bootstrap_options = c("striped", "condensed", full_width = F), font_size = 11)
TA vs DIC equations by season without extreme events
Zone Sub_region Season term estimate std.error statistic p.value r.squared adj.r.squared sigma
Inshore BB Winter DIC_umol_kg 0.67 0.10 6.59 0.00 0.74 0.73 23.70
Inshore BB Spring DIC_umol_kg 0.86 0.11 7.52 0.00 0.75 0.74 36.03
Inshore BB Summer DIC_umol_kg 0.54 0.15 3.61 0.00 0.48 0.45 37.42
Inshore BB Fall DIC_umol_kg 0.80 0.09 8.72 0.00 0.80 0.79 22.56
Inshore UK Winter DIC_umol_kg 0.71 0.05 13.83 0.00 0.91 0.90 21.12
Inshore UK Spring DIC_umol_kg 0.58 0.06 8.96 0.00 0.76 0.75 22.93
Inshore UK Summer DIC_umol_kg 0.80 0.27 2.92 0.01 0.28 0.25 42.64
Inshore UK Fall DIC_umol_kg 0.72 0.06 11.23 0.00 0.85 0.84 27.46
Inshore MK Winter DIC_umol_kg 0.84 0.08 10.16 0.00 0.84 0.83 34.06
Inshore MK Spring DIC_umol_kg 0.84 0.10 8.32 0.00 0.68 0.67 41.83
Inshore MK Summer DIC_umol_kg 1.08 0.10 11.08 0.00 0.85 0.85 37.41
Inshore MK Fall DIC_umol_kg 0.82 0.07 11.50 0.00 0.83 0.82 27.51
Inshore LK Winter DIC_umol_kg 0.64 0.12 5.22 0.00 0.51 0.49 44.09
Inshore LK Spring DIC_umol_kg 0.87 0.08 10.52 0.00 0.77 0.76 35.49
Inshore LK Summer DIC_umol_kg 0.90 0.12 7.58 0.00 0.76 0.75 39.84
Inshore LK Fall DIC_umol_kg 1.08 0.06 17.96 0.00 0.91 0.91 25.26
Mid channel BB Winter DIC_umol_kg 0.80 0.12 6.54 0.00 0.75 0.74 9.85
Mid channel BB Spring DIC_umol_kg 0.64 0.08 7.88 0.00 0.80 0.78 11.95
Mid channel BB Summer DIC_umol_kg 0.61 0.36 1.71 0.11 0.17 0.11 21.37
Mid channel BB Fall DIC_umol_kg 0.56 0.11 5.32 0.00 0.63 0.60 11.63
Mid channel UK Winter DIC_umol_kg 0.66 0.09 7.62 0.00 0.82 0.80 13.29
Mid channel UK Spring DIC_umol_kg 0.01 0.13 0.04 0.97 0.00 -0.07 13.59
Mid channel UK Summer DIC_umol_kg 1.09 0.32 3.45 0.00 0.50 0.46 17.14
Mid channel UK Fall DIC_umol_kg 0.57 0.13 4.44 0.00 0.57 0.54 14.12
Mid channel MK Winter DIC_umol_kg 0.72 0.07 10.08 0.00 0.82 0.81 21.50
Mid channel MK Spring DIC_umol_kg 0.97 0.08 11.47 0.00 0.81 0.80 29.81
Mid channel MK Summer DIC_umol_kg 1.25 0.10 12.61 0.00 0.88 0.87 21.92
Mid channel MK Fall DIC_umol_kg 0.63 0.06 10.51 0.00 0.80 0.79 14.44
Mid channel LK Winter DIC_umol_kg 0.73 0.14 5.10 0.00 0.48 0.46 35.75
Mid channel LK Spring DIC_umol_kg 0.74 0.08 9.40 0.00 0.73 0.73 27.01
Mid channel LK Summer DIC_umol_kg 0.97 0.06 15.11 0.00 0.92 0.92 18.73
Mid channel LK Fall DIC_umol_kg 0.82 0.16 4.96 0.00 0.44 0.42 19.50
Offshore BB Winter DIC_umol_kg 0.74 0.12 5.98 0.00 0.70 0.68 8.49
Offshore BB Spring DIC_umol_kg 0.48 0.13 3.63 0.00 0.41 0.38 8.38
Offshore BB Summer DIC_umol_kg 0.84 0.37 2.27 0.04 0.27 0.22 21.24
Offshore BB Fall DIC_umol_kg 0.32 0.11 2.93 0.01 0.32 0.29 8.97
Offshore UK Winter DIC_umol_kg 0.63 0.08 8.01 0.00 0.75 0.74 6.58
Offshore UK Spring DIC_umol_kg 0.48 0.17 2.86 0.01 0.25 0.22 10.70
Offshore UK Summer DIC_umol_kg 0.93 0.14 6.78 0.00 0.70 0.68 9.77
Offshore UK Fall DIC_umol_kg 0.48 0.11 4.36 0.00 0.44 0.42 10.84
Offshore MK Winter DIC_umol_kg 0.62 0.09 6.95 0.00 0.68 0.66 8.56
Offshore MK Spring DIC_umol_kg 0.89 0.07 12.65 0.00 0.84 0.83 13.80
Offshore MK Summer DIC_umol_kg 0.99 0.08 11.80 0.00 0.86 0.86 12.32
Offshore MK Fall DIC_umol_kg 0.43 0.09 5.03 0.00 0.47 0.45 9.97
Offshore LK Winter DIC_umol_kg 0.48 0.09 5.28 0.00 0.47 0.45 10.09
Offshore LK Spring DIC_umol_kg 0.61 0.08 7.90 0.00 0.61 0.60 11.79
Offshore LK Summer DIC_umol_kg 0.89 0.14 6.41 0.00 0.60 0.59 12.52
Offshore LK Fall DIC_umol_kg 0.30 0.08 3.52 0.00 0.24 0.22 7.99
Oceanic UK Winter DIC_umol_kg 0.74 0.10 7.49 0.00 0.90 0.89 4.81
Oceanic UK Spring DIC_umol_kg 0.17 0.21 0.82 0.44 0.09 -0.04 5.84
Oceanic UK Summer DIC_umol_kg 0.86 0.31 2.79 0.05 0.66 0.58 11.68
Oceanic UK Fall DIC_umol_kg 0.33 0.22 1.51 0.18 0.28 0.16 10.94
Oceanic MK Winter DIC_umol_kg 0.58 0.07 8.35 0.00 0.83 0.82 5.13
Oceanic MK Spring DIC_umol_kg 0.45 0.12 3.77 0.00 0.47 0.44 8.16
Oceanic MK Summer DIC_umol_kg 0.79 0.11 7.49 0.00 0.80 0.79 6.42
Oceanic MK Fall DIC_umol_kg 0.32 0.12 2.60 0.02 0.27 0.23 10.20
Oceanic LK Winter DIC_umol_kg 0.45 0.15 3.02 0.01 0.35 0.31 11.24
Oceanic LK Spring DIC_umol_kg 0.51 0.11 4.73 0.00 0.53 0.50 8.38
Oceanic LK Summer DIC_umol_kg 0.66 0.13 4.94 0.00 0.69 0.66 7.63
Oceanic LK Fall DIC_umol_kg 0.27 0.12 2.18 0.04 0.22 0.17 7.33
#write.csv (TA_DIC_coef_Season_noExtremes, "FLK_results/Fig_5_TA_DIC_slopes_Reefs.csv", row.names = FALSE)
  
  
  TA_DIC_coef_Season_noExtremes <- FLK.data[FLK.data$Extreme=="Normal", ] %>% 
                    group_by(Zone, Region, Sub_region, Season, Transect) %>%
                    do({model = lm(TA_umol_kg~DIC_umol_kg, data=.)  
                    # create model
                    data.frame(tidy(model), # get coefficient info
                    glance(model))})        # get model info
Slopes_season<-subset(TA_DIC_coef_Season_noExtremes, term!="(Intercept)")

Slope_plot<-ggplot(data=Slopes_season, aes (x =Zone, y =estimate)) +
  MyTheme+
  Zone_shapes4+
  geom_boxplot(aes(fill=Season), alpha=0.5,
               position=position_dodge(width=0.3))+
  geom_point(aes(fill = factor(Season)), 
              position=position_dodge(width=0.3),
             shape = 21, size=0.5)+
  scale_y_continuous(#limits = c(1700,2900),
                     #expand = c(0, 0),
                     #breaks = seq(1800, 2800, 100),
                     expression(paste("TA vs DIC slope")))+
  facet_grid(Sub_region~Region)+
  Season_fill+
  Season_colour+
  guides(fill=FALSE)+
  theme(axis.text.x = element_text(angle = 90, vjust = 0.1),
        legend.position = "bottom")
#Slope_plot

Figure 6: TA (µmol kg−1) vs DIC (µmol kg−1) slopes per season and reef

5 Seasonal plots

Data for endmember comparisons

# Reef
  WS.reef<-subset(FLK.data, FLK.data$Zone!="Oceanic")
  WS.reef$Date<-as.Date(WS.reef$Date, "%Y-%m-%d")
  
# Open
  WS.open<-subset(FLK.data_filtered,
                  FLK.data_filtered$Zone=="Oceanic")
  WS.open$Date<-as.Date(WS.open$Date, "%Y-%m-%d")
  #summary(WS.open)
# Mean ocean values by month - year 
  mean_Open_MY<- ddply (WS.open, .(MY, Month),
                            summarise,
                  OTem_my = mean (Temperature_C, na.rm = T),  
                  OSal_my = mean (BestSalinity, na.rm = T), 
                  
                  OTA_my = mean (TA_umol_kg, na.rm = T),
                  OnTA_my = mean (n35TA, na.rm = T),
                  
                  ODIC_my = mean (DIC_umol_kg, na.rm = T),
                  OnDIC_my = mean (n35DIC, na.rm = T),
                  
                  OpCO2_O = mean (pCO2_uatm , na.rm = T),
                  OpH_O = mean (pH_calculated, na.rm = T),
                  OAra_O = mean (Aragonite_Sat_W , na.rm = T)
                  )

# Mean ocean values by month
  mean_OpM <- mean_Open_MY %>%
              group_by(Month) %>%
              summarise(
                  OTem_m = mean (OTem_my, na.rm = T), 
                  OSal_m = mean (OSal_my, na.rm = T), 
                  
                  OTA_m = mean (OTA_my, na.rm = T),
                  OnTA_m = mean (OnTA_my, na.rm = T),
                  
                  OnDIC_m = mean (OnDIC_my, na.rm = T),
                  ODIC_m = mean (ODIC_my, na.rm = T),
                  
                  OpCO2_m = mean (OpCO2_O , na.rm = T),
                  OpH_m = mean (OpH_O, na.rm = T),
                  OAra_m = mean (OAra_O, na.rm = T),
                  n = n()
                  )
   #mean_OpM
  
 # Mean ocean values by year    
  mean_Op<- mean_OpM %>%
            summarise(
                  OTem = mean (OTem_m, na.rm = T), 
                  OSal  = mean (OSal_m, na.rm = T), 
                  
                  OTA = mean (OTA_m, na.rm = T),
                  OnTA = mean (OnTA_m, na.rm = T),
                  
                  OnDIC = mean (OnDIC_m, na.rm = T),
                  ODIC = mean (ODIC_m, na.rm = T),
                  
                  OpCO2 = mean (OpCO2_m, na.rm = T),
                  OpH = mean (OpH_m, na.rm = T),
                  OAra = mean (OAra_m, na.rm = T),
                  n = n()
                  )

5.1 Month raw values

- Months stats

Month_Stats<- ddply (FLK.data_filtered, .(Zone, Sub_region, Season, Month2, Region),
                            summarise,
                       
                  Tem_mean = mean (Temperature_C, na.rm = T),
                  Tem_sd = sd (Temperature_C, na.rm = T),
                  #Tem_se = std.error (Temperature_C, na.rm = T),
                  
                  Sal_mean = mean (BestSalinity, na.rm = T),
                  Sal_sd = sd (BestSalinity, na.rm = T),
                  #Sal_se = std.error (BestSalinity, na.rm = T),
                       
                  TA_mean = mean (TA_umol_kg, na.rm = T),
                  TA_sd = sd (TA_umol_kg, na.rm = T),
                  #TA_se = std.error (TA_umol_kg, na.rm = T),
                  
                  nTA_mean = mean (n35TA, na.rm = T),
                  nTA_sd = sd (n35TA, na.rm = T),
                  
                  DIC_mean = mean (DIC_umol_kg, na.rm = T),
                  DIC_sd = sd (DIC_umol_kg, na.rm = T),
                  #DIC_se = std.error (DIC_umol_kg, na.rm = T),
                  
                  nDIC_mean = mean (n35DIC, na.rm = T),
                  nDIC_sd = sd (n35DIC, na.rm = T),
                  
                  pCO2_mean = mean (pCO2_uatm , na.rm = T),
                  pCO2_sd = sd (pCO2_uatm , na.rm = T),
                  #pCO2_se = std.error (pCO2_uatm, na.rm = T),
                  
                  pH_mean = mean (pH_calculated, na.rm = T),
                  pH_sd = sd (pH_calculated, na.rm = T),
                  #pH_se = std.error (pH_calculated, na.rm = T),
                  
                  Ara_mean = mean (Aragonite_Sat_W , na.rm = T),
                  Ara_sd = sd (Aragonite_Sat_W , na.rm = T),
                  #Ara_se = std.error (Aragonite_Sat_W, na.rm = T),
                  n = n())

Month_Stats_2d<-Month_Stats %>% 
 mutate_if(is.numeric, round, digits=3)
Month_Stats_2d
#write.csv(Month_Stats, "FLK_results/Table_S7_Month_Stats.csv", row.names = F)

Temp

Month_Temp<- ddply (FLK.data_filtered, .(Zone, Sub_region, Season, Month2, Region), summarise,
                     
                  mean = mean (Temperature_C, na.rm = T),
                  sd = sd (Temperature_C, na.rm = T))

Month_Temp<-Month_Temp %>% 
 mutate_if(is.numeric, round, digits=2)
Month_Temp$Region<-NULL

Month_Temp<-reshape(Month_Temp, idvar = c("Sub_region", 
                                          "Season", "Month2"),
                    timevar = "Zone", direction = "wide")

Sal

Month_Sal<- ddply (FLK.data_filtered, .(Zone, Sub_region, Season, Month2, Region), summarise,
                     
                  mean = mean (BestSalinity, na.rm = T),
                  sd = sd (BestSalinity, na.rm = T))

Month_Sal<-Month_Sal %>% 
 mutate_if(is.numeric, round, digits=2)
Month_Sal$Region<-NULL

Month_Sal<-reshape(Month_Sal, idvar = c("Sub_region", 
                                          "Season", "Month2"),
                    timevar = "Zone", direction = "wide")

TA

Month_TA<- ddply (FLK.data_filtered, .(Zone, Sub_region, Season, Month2, Region), summarise,
                     
                  mean = mean (TA_umol_kg, na.rm = T),
                  sd = sd (TA_umol_kg, na.rm = T))

Month_TA<-Month_TA %>% 
 mutate_if(is.numeric, round, digits=2)
Month_TA$Region<-NULL

Month_TA<-reshape(Month_TA, idvar = c("Sub_region", 
                                          "Season", "Month2"),
                    timevar = "Zone", direction = "wide")

DIC

Month_DIC<- ddply (FLK.data_filtered, .(Zone, Sub_region, Season, Month2, Region), summarise,
                     
                  mean = mean (DIC_umol_kg, na.rm = T),
                  sd = sd (DIC_umol_kg, na.rm = T))

Month_DIC<-Month_DIC %>% 
 mutate_if(is.numeric, round, digits=2)
Month_DIC$Region<-NULL

Month_DIC<-reshape(Month_DIC, idvar = c("Sub_region", 
                                          "Season", "Month2"),
                    timevar = "Zone", direction = "wide")

pCO2

Month_pCO2<- ddply (FLK.data_filtered, .(Zone, Sub_region, Season, Month2, Region), summarise,
                     
                  mean = mean (pCO2_uatm , na.rm = T),
                  sd = sd (pCO2_uatm , na.rm = T))

Month_pCO2<-Month_pCO2 %>% 
 mutate_if(is.numeric, round, digits=2)
Month_pCO2$Region<-NULL

Month_pCO2<-reshape(Month_pCO2, idvar = c("Sub_region", 
                                          "Season", "Month2"),
                    timevar = "Zone", direction = "wide")

pH

Month_pH<- ddply (FLK.data_filtered, .(Zone, Sub_region, Season, Month2, Region), summarise,
                     
                  mean = mean (pH_calculated, na.rm = T),
                  sd = sd (pH_calculated, na.rm = T))

Month_pH<-Month_pH %>% 
 mutate_if(is.numeric, round, digits=2)
Month_pH$Region<-NULL

Month_pH<-reshape(Month_pH, idvar = c("Sub_region", 
                                          "Season", "Month2"),
                    timevar = "Zone", direction = "wide")

Arag

Month_Ara<- ddply (FLK.data_filtered, .(Zone, Sub_region, Season, Month2, Region), summarise,
                     
                  mean = mean (Aragonite_Sat_W , na.rm = T),
                  sd = sd (Aragonite_Sat_W , na.rm = T))

Month_Ara<-Month_Ara %>% 
 mutate_if(is.numeric, round, digits=2)
Month_Ara$Region<-NULL

Month_Ara<-reshape(Month_Ara, idvar = c("Sub_region", 
                                          "Season", "Month2"),
                    timevar = "Zone", direction = "wide")

all

Month_Stats3<-rbind(Month_Temp, Month_Sal, Month_TA, Month_DIC, 
      Month_pCO2, Month_pH, Month_Ara)

#write.csv(Month_Stats3, "FLK_results/Table_S7_Month_Stats_wide.csv", row.names = F)

Seasonal range

Seasonal_range<-ddply (Month_Stats, .(Zone, Sub_region),
                            summarise,
                  Tem_meany = mean (Tem_mean, na.rm = T),
                  Tem_sdy = sd (Tem_mean, na.rm = T),
                  Tem_max = max (Tem_mean, na.rm = T),
                  Tem_min = min (Tem_mean, na.rm = T),
                  Tem_diff = (max (Tem_mean, na.rm = T) - min (Tem_mean, na.rm = T)),
                  
                  Sal_meany = mean (Sal_mean, na.rm = T),
                  Sal_sdy = sd (Sal_mean, na.rm = T),
                  Sal_max = max (Sal_mean, na.rm = T),
                  Sal_min = min (Sal_mean, na.rm = T),
                  Sal_diff = (max (Sal_mean, na.rm = T) - min (Sal_mean, na.rm = T)),
                  
                  TA_meany = mean (TA_mean, na.rm = T),
                  TA_sdy = sd (TA_mean, na.rm = T), 
                  TA_max = max (TA_mean, na.rm = T),
                  TA_min = min (TA_mean, na.rm = T),
                  TA_diff = (max (TA_mean, na.rm = T) - min (TA_mean, na.rm = T)),
                  
                  DIC_meany = mean (DIC_mean, na.rm = T),
                  DIC_sdy = sd (DIC_mean, na.rm = T), 
                  DIC_max = max (DIC_mean, na.rm = T),
                  DIC_min = min (DIC_mean, na.rm = T),
                  DIC_diff = (max (DIC_mean, na.rm = T) - min (DIC_mean, na.rm = T)),
                  
                  pCO2_meany = mean (pCO2_mean, na.rm = T),
                  pCO2_sdy = sd (pCO2_mean, na.rm = T), 
                  pCO2_max = max (pCO2_mean, na.rm = T),
                  pCO2_min = min (pCO2_mean, na.rm = T),
                  pCO2_dif = (max (pCO2_mean, na.rm = T) - min (pCO2_mean, na.rm = T)),
                  
                  pH_meany = mean (pH_mean, na.rm = T),
                  pH_sdy = sd (pH_mean, na.rm = T), 
                  pH_max = max (pH_mean, na.rm = T),
                  pH_min = min (pH_mean, na.rm = T),
                  pH_diff = (max (pH_mean, na.rm = T) - min (pH_mean, na.rm = T)),
                  
                  Arg_meany = mean (Ara_mean, na.rm = T),
                  Arg_sdy = sd (Ara_mean, na.rm = T),  
                  Ara_max = max (Ara_mean, na.rm = T),
                  Ara_min = min (Ara_mean, na.rm = T),
                  Ara_diff = (max (Ara_mean, na.rm = T) - min (Ara_mean, na.rm = T)),
                  
                  
                  nTA_max = max (nTA_mean, na.rm = T),
                  nTA_min = min (nTA_mean, na.rm = T),
                  nTA_diff = (max (nTA_mean, na.rm = T) - min (nTA_mean, na.rm = T)),
                  
                  nDIC_max = max (nDIC_mean, na.rm = T),
                  nDIC_min = min (nDIC_mean, na.rm = T),
                  nDIC_diff = (max (nDIC_mean, na.rm = T) - min (nDIC_mean, na.rm = T)),
                  
                  n = n())

Seasonal_range<-Seasonal_range %>% 
 mutate_if(is.numeric, round, digits=2)
Seasonal_range
#Seasonal_range$pH_max_diff<-Seasonal_range$pH_max-mean()

#write.csv(Seasonal_range, "FLK_results/Table_S8_Month_mean_range.csv", row.names = F)

- Month Plots

Month_ploth<- ggplot(FLK.data) +
        MyTheme + 
        facet_grid(Sub_region~Zone)+
        scale_shape_manual(values=c(24, 25, 23, 22, 21))+
        guides(fill=guide_legend(override.aes=list(shape=21)))+
        theme(axis.title.x = element_blank() )

Year_ploth<- ggplot(Month_Stats) +
        MyTheme +  
        theme(axis.title.x = element_blank(), axis.text.x=element_text(angle = 10, vjust = 0.5))+
        Season_fill+
        Season_colour+
        facet_grid(Sub_region~Region)
        #scale_shape_manual(values=c(24, 25, 21))+
        #guides(fill=guide_legend(override.aes=list(shape=21)))+
        #theme(axis.title.x = element_blank() )

Month_Season_plotTA_DIC<- ggplot(FLK.data_filtered[
          FLK.data_filtered$Zone!="Oceanic",]) +
        MyTheme +  
        facet_grid(~Zone)+
        guides(fill=guide_legend(override.aes=list(shape=21)))+
        scale_x_continuous(limits = c(1,12),
                     expand = c(0.05, 0.05),
                     breaks = seq(1, 12, 1),
                     name=expression(paste("Month of the year")))+
        theme(#strip.text = element_blank(),
              legend.position = "none",
              axis.title.x = element_blank()
              )

Month_Season_plot<- ggplot(FLK.data_filtered) +
        MyTheme +  
        facet_grid(~Zone)+
        Zone_shapes4+
        #Region_fill+
        #Region_colour+
        guides(fill=guide_legend(override.aes=list(shape=21)))+
        scale_x_continuous(limits = c(1,12),
                   expand = c(0.05, 0.05),
                   breaks = seq(1, 12, 1),
                   name=expression(paste("Month of the year")))+
        theme(axis.title.x = element_blank())#,
        #       legend.position = "none")

Year_plot_2<- ggplot(Month_Stats)+
#[Month_Stats$Zone!="Oceanic",]) +
        MyTheme +  
        facet_grid(~Zone)+
        Zone_shapes4+
        guides(fill=guide_legend(override.aes=list(shape=21)))+
        #Season_fill+
        #Season_colour+
        theme(#axis.title.x = element_blank()#,
              #axis.text.y=element_blank(),
              legend.position = "bottom"
              )

Year_plot_3<- ggplot(Month_Stats, aes(fill=Sub_region, shape=Zone))+
#[Month_Stats$Zone!="Oceanic",]) +
        MyTheme +  
        Zone_shapes4+
        facet_grid(~Region)+
        guides(fill=guide_legend(override.aes=list(shape=21)))+
        theme(#axis.title.x = element_blank()#,
              #axis.text.y=element_blank(),
              legend.position = "right",
              axis.title.x = element_blank(),
              axis.text.x = element_text(angle = 20, vjust = 0.5)
              )

Temperature

Figure Supp 2: Temperature variation by the region and shelf position by (A) month of the year and (B) season.

Temp_exp<- Month_Season_plot+
  geom_abline(slope = 0, intercept = mean_Op$OTem, color="grey")+
    scale_y_continuous(#limits = c(15,40),
                       name=(expression("Temperature"~(degree*C))),
                       breaks = seq(16, 40, 2),  
                       expand = c(0.05, 0.05)) +
  
    geom_smooth(aes (x=as.numeric(Month2),
                      y=Temperature_C, colour=Sub_region),
                span=0.6, alpha=0.2, se=F)+
    stat_summary(aes (x=as.numeric(Month2),
                      y=Temperature_C, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.3))+
    stat_summary(aes (x=as.numeric(Month2), 
                      y=Temperature_C, fill=Sub_region, shape=Zone),
                size=1,
                fun.data = "mean_cl_boot", geom = "point",
                position=position_dodge(width=0.3))
    
#Temp_exp

Salinity

##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   19.37   23.40   24.63   24.53   25.86   27.96

Figure Supp 3: Salinity variation by the region and shelf position by (A) month of the year and (B) season.

Sal_exp<- Month_Season_plot+
  geom_abline(slope = 0, intercept = mean_Op$OSal, color="grey")+
   scale_y_continuous(#limits = c(15,40),
                       name=(expression("Salinity")),
                       breaks = seq(15, 40, 1),  
                       expand = c(0.05, 0.05)) +
  
    geom_smooth(aes (x=as.numeric(Month2),
                      y=BestSalinity, colour=Sub_region),
                span=0.8, alpha=0.2, se=F)+
    stat_summary(aes (x=as.numeric(Month2),
                      y=BestSalinity, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.3))+
    stat_summary(aes (x=as.numeric(Month2), 
                      y=BestSalinity, fill=Sub_region, shape=Zone),
                size=1,
                fun.data = "mean_cl_boot", geom = "point",
                position=position_dodge(width=0.3))
    
#Sal_exp

TA

##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    2045    2365    2464    2455    2561    2728

Figure Supp XX: Total Alkalinity (TA) variation by the region and shelf position by (A) month of the year and (B) season.

Figure 3A

TA_exp<- Month_Season_plot+
   geom_abline(slope = 0, intercept = mean_Op$OTA, color="grey")+
   scale_y_continuous(#limits = c(2100,2500),
                     expand = c(0.05, 0.05),
                     breaks = seq(2100, 2500, 100),
                     name=expression(paste("TA (", mu, "mol ", kg^-1, ")")))+
  
  # geom_smooth(data=FLK.data, se=F, colour="gray70", alpha=0.5, size=0.5,
  #               aes(x=as.numeric(Month2), y=Temp.adj))+
  
    geom_smooth(aes (x=as.numeric(Month2),
                      y=TA_umol_kg, colour=Sub_region),
                span=0.8, alpha=0.2, se=F)+
    stat_summary(aes (x=as.numeric(Month2),
                      y=TA_umol_kg, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.3))+
    stat_summary(aes (x=as.numeric(Month2), 
                      y=TA_umol_kg, fill=Sub_region, shape=Zone),
                size=1,
                fun.data = "mean_cl_boot", geom = "point",
                position=position_dodge(width=0.3))
    
#


TA_Y2<- Year_plot_2+
   geom_abline(slope = 0, intercept = mean_Op$OTA, color="grey")+
   scale_y_continuous(#limits = c(2150,2550),
                     expand = c(0.05, 0.05),
                     breaks = seq(2200, 2500, 50),
                    name=expression(paste("TA (", mu, "mol ", kg^-1, ")")))+
  
   stat_summary(aes (x=Sub_region, y=TA_mean, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2)+
   stat_summary(aes (x=Sub_region, y=TA_mean, fill=Sub_region, shape=Zone),
                fun.data = "mean_cl_boot", geom = "point", 
                size=2)
#TA_Y2

TA_Y3<- Year_plot_3+
   geom_abline(slope = 0, intercept = mean_Op$OTA, color="grey")+
   scale_y_continuous(limits = c(2130,2510),
                     expand = c(0.05, 0.05),
                     breaks = seq(2100, 2500, 100),
                     name=expression(paste("TA (", mu, "mol ", kg^-1, ")")))+
  
   geom_point(data=Seasonal_range, aes (x=Zone, y=TA_max,
                   shape=Zone, colour=Sub_region),
              alpha=0.8, size=1,
              position = position_dodge(width = 0.6))+
   geom_point(data=Seasonal_range, aes (x=Zone, y=TA_min,
                   shape=Zone, colour=Sub_region),
              alpha=0.8, size=1,
              position = position_dodge(width = 0.6))+
   # geom_segment(data=Seasonal_range, 
   #              aes(   x = Zone, y = TA_min, 
   #                  xend = Zone, yend = TA_max,
   #                  colour=Sub_region),
   #              #position = position_dodge(width = 0.6), 
   #              alpha=0.3)+
   stat_summary(aes (x=Zone, y=TA_mean, colour=Sub_region),
               fun.data = "mean_sdl", fun.args = list(mult = 1),
                geom = "errorbar",  width = 0.2,
                position = position_dodge(width = 0.6))+
   stat_summary(aes (x=Zone, y=TA_mean, fill=Sub_region, shape=Zone),
                fun = "mean", 
                geom = "point", size=2,
                position = position_dodge(width = 0.6))
#TA_Y3

Figure 3A: Total Alkalinity (TA) variation by the region and shelf position. Left: monthly mean values, Right: Yearly mean values

DIC

##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    1702    2003    2096    2088    2188    2345

Figure Supp XX: Disolved Inorganic Carbon (DIC) variation by the region and shelf position by (A) month of the year and (B) season.

Figure 3B

DIC_exp<- Month_Season_plot+
   geom_abline(slope = 0, intercept = mean_Op$ODIC, color="grey")+
   scale_y_continuous(#limits = c(1780,2270),
                     expand = c(0.05, 0.05),
                     breaks = seq(1800, 2800, 100),
                     name=expression(paste("DIC (", mu, "mol ", kg^-1, ")")))+
    geom_smooth(aes (x=as.numeric(Month2),
                    y=DIC_umol_kg, colour=Sub_region),
                    span=0.8, alpha=0.2, se=F)+
   
    stat_summary(aes (x=as.numeric(Month2),
                      y=DIC_umol_kg, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width=0.2,
                position=position_dodge(width=0.3))+
    stat_summary(aes (x=as.numeric(Month2), 
                      y=DIC_umol_kg, fill=Sub_region, shape=Zone),
                size=1,
                fun = "mean", geom = "point",
                position=position_dodge(width=0.3))
#DIC_exp

DIC_Y2<- Year_plot_2+
   geom_abline(slope = 0, intercept = mean_Op$ODIC, color="grey")+
   scale_y_continuous(#limits = c(1700,2900),
                     expand = c(0.05, 0.05),
                     #breaks = seq(1800, 2800, 100),
                     name=expression(paste("DIC (", mu, "mol ", kg^-1, ")")))+
    
   stat_summary(aes (x=Sub_region, y=DIC_mean, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar",  width = 0.2)+
   stat_summary(aes (x=Sub_region, y=DIC_mean, fill=Sub_region, shape=Zone),
                fun.data = "mean_cl_boot", geom = "point",
                size=2)
#DIC_Y2

DIC_Y3<- Year_plot_3+
   geom_abline(slope = 0, intercept = mean_Op$ODIC, color="grey")+
   scale_y_continuous(limits = c(1820,2230),
                     expand = c(0.00, 0.00),
                     breaks = seq(1800, 2800, 100),
                     name=expression(paste("DIC (", mu, "mol ", kg^-1, ")")))+
  
   geom_point(data=Seasonal_range, aes (x=Zone, y=DIC_max,
                   shape=Zone, colour=Sub_region),
              alpha=0.8, size=1,
              position = position_dodge(width = 0.6))+
   geom_point(data=Seasonal_range, aes (x=Zone, y=DIC_min,
                   shape=Zone, colour=Sub_region),
              alpha=0.8, size=1,
              position = position_dodge(width = 0.6))+
  # geom_segment(data=Seasonal_range, 
  #               aes(   x = Zone, y = DIC_min, 
  #                   xend = Zone, yend = DIC_max,
  #                   colour=Sub_region),
  #               #position = position_dodge(width = 0.6), 
  #               alpha=0.3)+
   stat_summary(aes (x=Zone, y=DIC_mean, colour=Sub_region),
               fun.data = "mean_sdl", fun.args = list(mult = 1),
                geom = "errorbar",  width = 0.2,
                position = position_dodge(width = 0.6))+
  stat_summary(aes (x=Zone, y=DIC_mean, fill=Sub_region, shape=Zone),
                fun = "mean", 
                geom = "point", size=2,
                position = position_dodge(width = 0.6))
#DIC_Y3

Figure 3B: Dissolved Inorganic Carbon (DIC) by the region and shelf position. Left: monthly mean values, Right: Yearly mean values

pCO2

##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   208.0   466.4   545.9   539.0   624.7   759.2

Figure Supp 6: pCO2 variation by the region and shelf position by (A) month of the year and (B) season.

pCO2_exp<- Month_Season_plot+
   geom_abline(slope = 0, intercept = mean_Op$OpCO2, color="grey")+
     scale_y_continuous(#limits = c(1,5.5),
                       name=expression(paste(pCO[2], " (", mu, " atm)")),
                       breaks = seq(200, 600, 100),
                       expand = c(0.05, 0.05)
                        ) +
  
    geom_smooth(aes (x=as.numeric(Month2),
                      y=pCO2_uatm, colour=Sub_region),
                span=0.8, se=F)+
    stat_summary(aes (x=as.numeric(Month2),
                      y=pCO2_uatm, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.2))+
     stat_summary(aes (x=as.numeric(Month2), 
                      y=pCO2_uatm, fill=Sub_region, shape=Zone),
                size=1,
                fun.data = "mean_cl_boot", geom = "point",
                position=position_dodge(width=0.2))
#pCO2_exp

pCO2_Y2<- Year_plot_2+
  geom_abline(slope = 0, intercept = mean_Op$OpCO2, color="grey")+
  scale_y_continuous(#limits = c(1,5.5),
                       name=expression(paste(pCO[2], 
                                             " (", mu, " atm)")),
                       breaks = seq(200, 600, 50),
                       expand = c(0.05, 0.05)
                        ) +
    
   stat_summary(aes (x=Sub_region, y=pCO2_mean, fill=Sub_region, shape=Zone),
                fun.data = "mean_cl_boot", geom = "point", 
                size=2)+
  stat_summary(aes (x=Sub_region, y=pCO2_mean, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar",  width = 0.2)
#pCO2_Y2

pH

##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   7.808   8.027   8.094   8.088   8.160   8.274

Figure Supp 7: pH variation by the region and shelf position by (A) month of the year and (B) season.

pH_exp<- Month_Season_plot+
    geom_abline(slope = 0, intercept = mean_Op$OpH, color="grey")+
    scale_y_continuous(#limits = c(7.88,8.25),
                       name=(expression (pH)),
                       breaks = seq(0, 9, 0.1),
                       expand = c(0.02, 0)
                        ) +
    
    geom_smooth(aes (x=as.numeric(Month2),
                      y=pH_calculated, colour=Sub_region),
                span=0.8, se=F)+
    
    stat_summary(aes (x=as.numeric(Month2),
                      y=pH_calculated, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.2))+
     stat_summary(aes (x=as.numeric(Month2), 
                      y=pH_calculated, fill=Sub_region, shape=Zone),
                size=1,
                fun.data = "mean_cl_boot", geom = "point",
                position=position_dodge(width=0.2))
#pH_exp

pH_Y2<- Year_plot_2+
  geom_abline(slope = 0, intercept = mean_Op$OpH, color="grey")+
    scale_y_continuous(#limits = c(1,5.5),
                       name=(expression (pH[calculated])),
                       breaks = seq(0, 9, 0.05),
                       expand = c(0.05, 0.05)
                        ) +
    
   stat_summary(aes (x=Sub_region, y=pH_mean, fill=Sub_region, shape=Zone),
                fun.data = "mean_cl_boot", geom = "point", 
                size=2)+
    stat_summary(aes (x=Sub_region, y=pH_mean, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar",  width = 0.2)
#pH_Y2

pH_Y3<- Year_plot_3+
   geom_abline(slope = 0, intercept = mean_Op$OpH, color="grey")+
   scale_y_continuous(limits = c(7.87,8.22),
                       name=(expression (pH)),
                       breaks = seq(0, 9, 0.1),
                       expand = c(0.02, 0)
                        )+
  
   geom_point(data=Seasonal_range, aes (x=Zone, y=pH_max,
                   shape=Zone, colour=Sub_region),
              alpha=0.8, size=1, 
              position = position_dodge(width = 0.6))+
   geom_point(data=Seasonal_range, aes (x=Zone, y=pH_min, 
                   shape=Zone, colour=Sub_region),
              alpha=0.8, size=1,
              position = position_dodge(width = 0.6))+
   # geom_segment(data=Seasonal_range, 
   #              aes(   x = Zone, y = pH_min, 
   #                  xend = Zone, yend = pH_max,
   #                  colour=Sub_region),
   #              #position = position_dodge(width = 0.6), 
   #              alpha=0.3)+
   stat_summary(aes (x=Zone, y=pH_mean, colour=Sub_region),
               fun.data = "mean_sdl", fun.args = list(mult = 1),
                geom = "errorbar",  width = 0.2,
                position = position_dodge(width = 0.6))+
  stat_summary(aes (x=Zone, y=pH_mean, fill=Sub_region, shape=Zone),
                fun = "mean", 
                geom = "point", size=2,
                position = position_dodge(width = 0.6))
#pH_Y3

Figure 3C

Omega

##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   2.246   3.597   4.013   3.977   4.425   5.129

Figure Supp 8: Omega variation by the region and shelf position by (A) month of the year and (B) season.

Figure 3D

Omega_exp<- Month_Season_plot+
    geom_abline(slope = 0, intercept = mean_Op$OAra, color="grey")+
    scale_y_continuous(#limits = c(1,5.5),
                       name=(expression("\n" ~Omega[Ar])),
                       breaks = seq(1, 5, 0.5),
                       expand = c(0.05, 0.05)
                        ) +
  
    geom_smooth(aes (x=as.numeric(Month2),
                      y=Aragonite_Sat_W, colour=Sub_region),
                span=0.8, alpha=0.2, se=F
                #method = lm, formula = y ~ splines::bs(x, 3),
                )+
      stat_summary(aes (x=as.numeric(Month2),
                      y=Aragonite_Sat_W, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.3))+
    stat_summary(aes (x=as.numeric(Month2), 
                      y=Aragonite_Sat_W, fill=Sub_region, shape=Zone),
                size=1,
                fun.data = "mean_cl_boot", geom = "point",
                position=position_dodge(width=0.3))

#Omega_exp

Om_Y2<- Year_plot_2+
  geom_abline(slope = 0, intercept = mean_Op$OAra, color="grey")+
  scale_y_continuous(#limits = c(1,5.5),
                       # name=(expression (
                       #   "Aragonite saturation state "(~Omega[Ar]))),
                      name=(expression (
                      ~Omega[Ar])),
                       breaks = seq(1, 5, 0.5),
                       expand = c(0.05, 0.05)
                        ) +
    
  stat_summary(aes (x=Sub_region, y=Ara_mean, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar",  width = 0.2)+
  stat_summary(aes (x=Sub_region, y=Ara_mean, fill=Sub_region, shape=Zone),
                fun.data = "mean_cl_boot", geom = "point", 
                size=2)
#Om_Y2

Om_Y3<- Year_plot_3+
   geom_abline(slope = 0, intercept = mean_Op$OAra , color="grey")+
  scale_y_continuous(#limits = c(1,5.5),
                       # name=(expression (
                       #   "Aragonite saturation state "(~Omega[Ar]))),
                      name=(expression (
                      ~Omega[Ar])),
                       breaks = seq(1, 5, 0.5),
                       expand = c(0.1, 0.1)
                        ) +
  
   geom_point(data=Seasonal_range, aes (x=Zone, y=Ara_max,
                   shape=Zone, colour=Sub_region),
              alpha=0.8, size=1, 
              position = position_dodge(width = 0.6))+
   geom_point(data=Seasonal_range, aes (x=Zone, y=Ara_min, 
                   shape=Zone, colour=Sub_region),
              alpha=0.8, size=1,
              position = position_dodge(width = 0.6))+
   # geom_segment(data=Seasonal_range, 
   #              aes(   x = Zone, y = Ara_min, 
   #                  xend = Zone, yend = Ara_max,
   #                  colour=Sub_region),
   #              #position = position_dodge(width = 0.6), 
   #              alpha=0.3)+
   stat_summary(aes (x=Zone, y=Ara_mean, colour=Sub_region),
               fun.data = "mean_sdl", fun.args = list(mult = 1),
                geom = "errorbar",  width = 0.2,
                position = position_dodge(width = 0.6))+
  stat_summary(aes (x=Zone, y=Ara_mean, fill=Sub_region, shape=Zone),
                fun = "mean", 
                geom = "point", size=2,
                position = position_dodge(width = 0.6))
#Om_Y3

Figure 3C: Aragonite saturation state (omega) by the region and shelf position. Left: monthly mean values, Right: Yearly mean values + SD, maximum monthly mean and minimum monthly mean.

Fig.3: Seasonal monthly plot

No summary

with summary

Fig.3: Seasonal monthly plot supplemental

Figure 3: Monthly seasonal patterns in (A) Total Alkalinity (TA), (B) Dissolved Inorganic Carbon (DIC), and (C) aragonite saturation state (Ωar) in the Florida Reef Tract. The colors represent the biogeographical regions and the vertical panels separate the locations by shelf zone. The points show the (monthly mean values ± 95 CI) and the lines the smoothed curves for the data (method = ‘loess’ and formula ‘y ~ x’, span=0.8). Gray horizontal lines in each panel demarcate the mean values of the parameters in the oceanic samples.

5.2 Season raw values

- Season stats (all data)

  • do not use for further calculations since some months have more data than
  • can be used to compare the aggregated meas ussing MM
Seasonal_Stats<- ddply (FLK.data_filtered, .(Zone, Sub_region, Season),
             summarise,

      Tem_mean = mean (Temperature_C, na.rm = T),
      Tem_sd = sd (Temperature_C, na.rm = T),
    
      Sal_mean = mean (BestSalinity, na.rm = T),
      Sal_sd = sd (BestSalinity, na.rm = T),
    
      TA_mean = mean (TA_umol_kg, na.rm = T),
      TA_sd = sd (TA_umol_kg, na.rm = T),
    
      nTA_mean = mean (n35TA, na.rm = T),
      nTA_sd = sd (n35TA, na.rm = T),
    
      nDIC_mean = mean (n35DIC, na.rm = T),
      nDIC_sd = sd (n35DIC, na.rm = T),
    
      DIC_mean = mean (DIC_umol_kg, na.rm = T),
      DIC_sd = sd (DIC_umol_kg, na.rm = T),
    
      pCO2_mean = mean (pCO2_uatm , na.rm = T),
      pCO2_sd = sd (pCO2_uatm , na.rm = T),
    
      pH_mean = mean (pH_calculated, na.rm = T),
      pH_sd = sd (pH_calculated, na.rm = T),
    
      Ara_mean = mean (Aragonite_Sat_W , na.rm = T),
      Ara_sd = sd (Aragonite_Sat_W , na.rm = T),
       n())

Seasonal_Stats<-Seasonal_Stats %>% 
 mutate_if(is.numeric, round, digits=2)
Seasonal_Stats

- Season stats (monthly mean)

Seasonal_Stats2<- ddply (Month_Stats, .(Zone, Sub_region, Season),
                         summarise,

                  Tem_M = mean (Tem_mean, na.rm = T),
                  #Tem_sd = sd (Tem_mean, na.rm = T),
                  Tem_se = std.error (Tem_mean, na.rm = T),

                  Sal_M = mean (Sal_mean, na.rm = T),
                  #Sal_sd = sd (Sal_mean, na.rm = T),
                  Sal_se = std.error (Sal_mean, na.rm = T),

                  TA_M = mean (TA_mean, na.rm = T),
                  #TA_sd = sd (TA_mean, na.rm = T),
                  TA_se = std.error (TA_mean, na.rm = T),
                  
                  DIC_M = mean (DIC_mean, na.rm = T),
                  #DIC_sd = sd (DIC_mean, na.rm = T),
                  DIC_se = std.error (DIC_mean, na.rm = T),
                  
                  #nTA_M = mean (nTA_mean, na.rm = T),
                  #nTA_sd = sd (nTA_mean, na.rm = T),
                  
                  #nDIC_M = mean (nDIC_mean, na.rm = T),
                  #nDIC_sd = sd (nDIC_mean, na.rm = T),

                  pCO2_M = mean (pCO2_mean , na.rm = T),
                  #pCO2_sd = sd (pCO2_mean , na.rm = T),
                  pCO2_se = std.error (pCO2_mean , na.rm = T),

                  pH_M = mean (pH_mean, na.rm = T),
                  #pH_sd = sd (pH_mean, na.rm = T),
                  pH_se = std.error (pH_mean, na.rm = T),

                  Ara_M = mean (Ara_mean , na.rm = T),
                  #Ara_sd = sd (Ara_mean , na.rm = T),
                  Ara_se = std.error (Ara_mean , na.rm = T),
                  n())

Seasonal_Stats2<-Seasonal_Stats2 %>% 
 mutate_if(is.numeric, round, digits=2)
Seasonal_Stats2
# write.csv(Seasonal_Stats2, "FLK_results/Table_S_Season_A.csv", row.names = F)

Note: SD is NA when calculating it based on monthly meand (n=3 per season)

- Yearly stats (monthly mean)

Yearly_Stats<- ddply (Month_Stats, .(Zone, Sub_region),
                         summarise,

                  Tem_Y = mean (Tem_mean, na.rm = T),
                  Tem_sd = sd (Tem_mean, na.rm = T),

                  Sal_Y = mean (Sal_mean, na.rm = T),
                  Sal_sd = sd (Sal_mean, na.rm = T),

                  TA_Y = mean (TA_mean, na.rm = T),
                  TA_sd = sd (TA_mean, na.rm = T),

                  nTA_Y = mean (nTA_mean, na.rm = T),
                  nTA_sd = sd (nTA_mean, na.rm = T),

                  nDIC_Y = mean (nDIC_mean, na.rm = T),
                  nDIC_sd = sd (nDIC_mean, na.rm = T),

                  DIC_Y = mean (DIC_mean, na.rm = T),
                  DIC_sd = sd (DIC_mean, na.rm = T),

                  pCO2_Y = mean (pCO2_mean , na.rm = T),
                  pCO2_sd = sd (pCO2_mean , na.rm = T),

                  pH_Y = mean (pH_mean, na.rm = T),
                  pH_sd = sd (pH_mean, na.rm = T),

                  Ara_Y = mean (Ara_mean , na.rm = T),
                  Ara_sd = sd (Ara_mean , na.rm = T),
                  n())

Yearly_Stats<-Yearly_Stats %>% 
 mutate_if(is.numeric, round, digits=2)
Yearly_Stats
# write.csv(Yearly_Stats, "FLK_results/Table_1_Year_A.csv", row.names = F)

Note: SD is NA when calculating it based on monthly meand (n=3 per season)

5.3 Delta months values

# 1. Get the oceanic mean values per month-year 

  WS.reef<-join(WS.reef, mean_Open_MY, 
                 type = "left", by=c("MY", "Month"))

# 2. and subtract them from the reef data
  # Delta TA
  WS.reef$dTA_MY<-WS.reef$TA_umol_kg-WS.reef$OTA_my
  # Delta DIC
  WS.reef$dDIC_MY<-WS.reef$DIC_umol_kg-WS.reef$ODIC_my
  # Delta nTA
  WS.reef$dnTA_MY<-WS.reef$n35TA-WS.reef$OnTA_my
  # Delta nDIC
  WS.reef$dnDIC_MY<-WS.reef$n35DIC-WS.reef$OnDIC_my
  # Delta pCO2
  WS.reef$dpCO2_MY<-WS.reef$pCO2_uatm-WS.reef$OpCO2_O
  # Delta pH
  WS.reef$dpH_MY<-WS.reef$pH_calculated-WS.reef$OpH_O
   # Delta Omega
  WS.reef$dOme_MY<-WS.reef$Aragonite_Sat_W-WS.reef$OAra_O
  
 # head(WS.reef)
 #summary(WS.reef$Season, digits=2)

- Delta month stats

dMonth_Stats<- ddply (WS.reef, .(Zone, Sub_region, Month2, Season, Region),
                            summarise,
                  dTA_mean = mean (dTA_MY, na.rm = T),
                  dTA_sd = sd (dTA_MY, na.rm = T),
                  #dTA_se = std.error (dTA_MY, na.rm = T),
                  
                  dnTA_mean = mean (dnTA_MY, na.rm = T),
                  dnTA_sd = sd (dnTA_MY, na.rm = T),
                 
                  dDIC_mean = mean (dDIC_MY, na.rm = T),
                  dDIC_sd = mean (dDIC_MY, na.rm = T),
                  #dDIC_se = std.error (dDIC_MY, na.rm = T),
                  
                  dnDIC_mean = mean (dnDIC_MY, na.rm = T),
                  dnDIC_sd = sd (dnDIC_MY, na.rm = T),
                  
                  dpCO2_mean = mean (dpCO2_MY , na.rm = T),
                  dpCO2_sd = sd (dpCO2_MY , na.rm = T),
                  #dpCO2_se = std.error (dpCO2_MY, na.rm = T),
                  
                  dpH_mean = mean (dpH_MY, na.rm = T),
                  dpH_sd = sd (dpH_MY, na.rm = T),
                  #dPH_se = std.error (dpH_MY, na.rm = T),
                  
                  dAra_mean = mean (dOme_MY , na.rm = T),
                  dAra_sd = sd (dOme_MY , na.rm = T)#,
                  #dAra_se = std.error (dOme_MY, na.rm = T),
                  )

dMonth_Stats<-dMonth_Stats %>% 
 mutate_if(is.numeric, round, digits=3)
dMonth_Stats
#write.csv(dMonth_Stats, "FLK_results/Table_S9_Month_StatsDeltas.csv", row.names = F)

Spring.data<-WS.reef[WS.reef$Season=="Spring", ]
Summer.data<-WS.reef[WS.reef$Season=="Summer", ]
Fall.data<-WS.reef[WS.reef$Season=="Fall", ]
Winter.data<-WS.reef[WS.reef$Season=="Winter", ]

Seasonal range

Seasonal_range_d<-ddply (dMonth_Stats, .(Zone, Sub_region),
                            summarise,

                  
                  dTA_max = max (dTA_mean, na.rm = T),
                  dTA_min = min (dTA_mean, na.rm = T),
                  dTA_diff = (max (dTA_mean, na.rm = T) - min (dTA_mean, na.rm = T)),
                  
                  dDIC_max = max (dDIC_mean, na.rm = T),
                  dDIC_min = min (dDIC_mean, na.rm = T),
                  dDIC_diff = (max (dDIC_mean, na.rm = T) - min (dDIC_mean, na.rm = T)),
                  
                  dpCO2_max = max (dpCO2_mean, na.rm = T),
                  dpCO2_min = min (dpCO2_mean, na.rm = T),
                  dpCO2_dif = (max (dpCO2_mean, na.rm = T) - min (dpCO2_mean, na.rm = T)),
                  
                  dpH_max = max (dpH_mean, na.rm = T),
                  dpH_min = min (dpH_mean, na.rm = T),
                  dpH_diff = (max (dpH_mean, na.rm = T) - min (dpH_mean, na.rm = T)),
                  
                  dAra_max = max (dAra_mean, na.rm = T),
                  dAra_min = min (dAra_mean, na.rm = T),
                  dAra_diff = (max (dAra_mean, na.rm = T) - min (dAra_mean, na.rm = T)),
                  
                  n = n())

Seasonal_range_d<-Seasonal_range_d %>% 
 mutate_if(is.numeric, round, digits=3)
Seasonal_range_d
#write.csv(Seasonal_range_d, "FLK_results/Table_S8_Month_mean_range_d.csv", row.names = F)

- Delta month plots

Delta_plot<- ggplot(WS.reef) +
        MyTheme +  
        facet_grid(Sub_region~Zone)+
        scale_shape_manual(values=c(24, 25, 23, 22, 21))+
        guides(fill=guide_legend(override.aes=list(shape=21)))+
        geom_hline(yintercept = 0, color="gray")+
        theme(axis.title.x = element_blank())

DeltaYear_plot<- ggplot(dMonth_Stats) +
        MyTheme +  
        facet_grid(Sub_region~Region)+
        Season_fill+
        Season_colour+
        geom_hline(yintercept = 0, color="gray")+
        theme(axis.title.x = element_blank(),
              axis.text.x = element_text(angle = 10,
                                         vjust = 0.5))
        
Delta_plot_month<- ggplot(WS.reef) +
        MyTheme +  
        geom_abline(slope = 0, intercept = 0, color="grey")+
        facet_grid(~Zone)+
        guides(fill=guide_legend(override.aes=list(shape=21)))+
        scale_x_continuous(limits = c(1,12),
                     expand = c(0.05, 0.05),
                     breaks = seq(1, 12, 1),
                     name=expression(paste("Month of the year")))+
        theme(axis.title.x = element_blank(),
              legend.position = "bottom")

DeltaYear_plot2<- ggplot(dMonth_Stats) +
        MyTheme +  
        #facet_grid(Zone~., scales = "free_y")+
        facet_grid(~Zone, scales="free" )+
        geom_hline(yintercept = 0, color="gray")+
        theme(axis.title.x = element_blank(),
              legend.position = "bottom",
              axis.text.x = element_text(angle = 0))

DeltaYear_plot3<- ggplot(dMonth_Stats) +
        MyTheme +  
        Zone_shapes3+
        facet_grid(~Region)+
        geom_hline(yintercept = 0, color="gray")+
        theme(axis.title.x = element_blank(),
              legend.position = "bottom",
              axis.text.x = element_text(angle = 0))

Frequency_plot<- ggplot(data = WS.reef) +
      geom_vline(aes(xintercept = 0), linetype = "dashed")+
      facet_grid(Zone~Sub_region, scales = "free_y")+ MyTheme

dTA

Figure Supp 4: Total Alkalinity (TA) variation by the region and shelf position by (A) month of the year and (B) season.

Figure 4A

DTA_exp<- Delta_plot_month+
   scale_y_continuous(#limits = c(-350,340),
                     expand = c(0.05, 0.05),
                     breaks = seq(-800, 800, 100),
                     name=expression(paste(Delta,
                          "TA  (", mu, "mol ", ~kg^-1, ")")))+
  
    geom_smooth(aes (x=as.numeric(Month2),
                      y=dTA_MY, colour=Sub_region),
                span=0.8, se=F)+
    stat_summary(aes (x=as.numeric(Month2),
                      y=dTA_MY, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.2))+
    stat_summary(aes (x=as.numeric(Month2), 
                      y=dTA_MY, fill=Sub_region),
                 shape=21, size=1,
                fun.data = "mean_cl_boot", geom = "point",
                position=position_dodge(width=0.2))

#DTA_exp

TA_delta_Y2<- DeltaYear_plot2+
    scale_y_continuous(#limits = c(-350,340),
                     expand = c(0.03, 0.03),
                     #breaks = seq(-800, 800, 50),
                     name=expression(paste(Delta, "TA  (", mu, "mol ", ~kg^-1, ")")))+
    stat_summary(aes (x=Season, y=dTA_mean, fill=Sub_region),
                fun.data = "mean_cl_boot", geom = "bar",
                position=position_dodge(width=0.8))+
    stat_summary(aes (x=Season, y=dTA_mean, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.8))
#TA_delta_Y2

dTA_Y3<- DeltaYear_plot3+
   scale_y_continuous(#limits = c(-210,70),
                     expand = c(0.03, 0.03),
                     #breaks = seq(0, 2500, 50),
                     name=expression(paste("")))+
    
   stat_summary(aes (x=Zone, y=dTA_mean,
                     fill=Sub_region, shape=Zone),
                fun.data = "mean_cl_boot", geom = "point", 
                size=1.5, 
                position=position_dodge(width=0.5))+
  stat_summary(aes (x=Zone, y=dTA_mean, colour=Sub_region),
               fun.data = "mean_cl_boot", 
               geom = "errorbar",  width = 0.2,
               position=position_dodge(width=0.5))+
  facet_grid(~Region)
#dTA_Y3

Figure 4A: Seasonal delta Total Alkalinity (dTA) variation by region and shelf position. Mean values and 95 CI

dDIC

Figure Supp 5: Total Alkalinity (TA) variation by the region and shelf position by (A) month of the year and (B) season.

Figure 4B

dDIC_exp<- Delta_plot_month+
   scale_y_continuous(#limits = c(1700,2900),
                     expand = c(0.05, 0.05),
                     breaks = seq(-800, 800, 100),
                     name=expression(paste(Delta, "DIC  (", mu, "mol ", ~kg^-1, ")")))+
  
    geom_smooth(aes (x=as.numeric(Month2),
                      y=dDIC_MY, colour=Sub_region),
                span=0.8, se=F)+
    stat_summary(aes (x=as.numeric(Month2),
                      y=dDIC_MY, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.2))+
    stat_summary(aes (x=as.numeric(Month2), 
                      y=dDIC_MY, fill=Sub_region),
                 shape=21, size=1,
                fun.data = "mean_cl_boot", geom = "point",
                position=position_dodge(width=0.2))

#dDIC_exp

DIC_delta_Y2<- DeltaYear_plot2+
    scale_y_continuous(#limits = c(-350,340),
                     expand = c(0.05, 0.05),
                     #breaks = seq(-800, 800, 50),
                     name=expression(paste(Delta, "DIC  (", mu, "mol ", ~kg^-1, ")")))+
    stat_summary(aes (x=Season, y=dDIC_mean, fill=Sub_region),
                fun.data = "mean_cl_boot", geom = "bar",
                position=position_dodge(width=0.8))+
    stat_summary(aes (x=Season, y=dDIC_mean, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.8))
  
#DIC_delta_Y2

dDIC_Y3<- DeltaYear_plot3+
   scale_y_continuous(#limits = c(-185,130),
                     expand = c(0.01, 0.01),
                     #breaks = seq(0, 2500, 50),
                     name=expression(paste("")))+
    
   stat_summary(aes (x=Zone, y=dDIC_mean, 
                     fill=Sub_region, shape = Zone), 
                fun.data = "mean_cl_boot", geom = "point", 
                size=1.5,
                position=position_dodge(width=0.5))+
  stat_summary(aes (x=Zone, y=dDIC_mean, colour=Sub_region),
                fun.data = "mean_cl_boot", 
               geom = "errorbar",   width = 0.2,
               position=position_dodge(width=0.5))
#dDIC_Y3

Figure 4B: Seasonal delta Dissolved Inorganic Carbon (dDIC) variation by region and shelf position.

dDIC density

dDIC_freq_All<- Frequency_plot+
  geom_density(aes (dDIC_MY), fill = "lightgray", alpha=0.5) +
  scale_x_continuous(breaks = seq(-300, 300, 100),
                     expression(paste(Delta, "DIC (", mu, "mol ", kg^-1, ")")))
#dDIC_freq_All

dDIC_freq_pre<- Frequency_plot+
  geom_density(aes (dDIC_MY, fill = Precipitation),
               alpha = 0.4) +
  scale_x_continuous(breaks = seq(-300, 300, 100),
                    expression(paste(Delta, "DIC (", mu, "mol ", kg^-1, ")")))
#dDIC_freq_pre

# dDIC_freq_sea<- Frequency_plot+
#   geom_density(aes (dDIC_MY, fill = Season), alpha = 0.4) +
#   scale_x_continuous(breaks = seq(-300, 300, 100),
#                      expression(paste(Delta, "DIC (", mu, "mol ", kg^-1, ")")))
# dDIC_freq_sea

dpCO2

pdCO2_exp<- Delta_plot_month+
   scale_y_continuous(#limits = c(1700,2900),
                     expand = c(0.05, 0.05),
                     #breaks = seq(1800, 2800, 100),
                     name=expression(paste(Delta ~ pCO[2] , " (", mu, "atm)")))+
  
    geom_smooth(aes (x=as.numeric(Month2),
                      y=dpCO2_MY, colour=Sub_region),
                span=0.8, se=F)+
    stat_summary(aes (x=as.numeric(Month2),
                      y=dpCO2_MY, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.2))+
    stat_summary(aes (x=as.numeric(Month2), 
                      y=dpCO2_MY, fill=Sub_region),
                 shape=21, size=1,
                fun.data = "mean_cl_boot", geom = "point",
                position=position_dodge(width=0.2))
#pdCO2_exp

pCO2_delta_Y2<- DeltaYear_plot2+
    scale_y_continuous(#limits = c(-350,340),
                     expand = c(0.1, 0.1),
                     #breaks = seq(-800, 800, 50),
                     name=expression(paste(Delta ~ pCO[2] , " (", mu, "atm)")))+
    stat_summary(aes (x=Season, y=dpCO2_mean, fill=Sub_region),
                fun.data = "mean_cl_boot", geom = "bar",
                position=position_dodge(width=0.8))+
    stat_summary(aes (x=Season, y=dpCO2_mean, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.8))
#pCO2_delta_Y2

dPCO2_Y3<- DeltaYear_plot2+
   scale_y_continuous(#limits = c(2150,2550),
                     expand = c(0.01, 0.01),
                     #breaks = seq(0, 2500, 50),
                     name=expression(paste("")))+
    
   stat_summary(aes (x=Sub_region, y=dpCO2_mean, fill=Sub_region),
                fun.data = "mean_cl_boot", geom = "point", 
                size=1.5, shape=21)+
    stat_summary(aes (x=Sub_region, y=dpCO2_mean, colour=Sub_region),
                fun.data = "mean_cl_boot", 
               geom = "errorbar",  width = 0.2)
#dPCO2_Y3

dpH

Figure 4C

dOmega

Figure 4D

DOmega_exp<- Delta_plot_month+
   scale_y_continuous(#limits = c(1,5.5),
                       name=(expression (paste(Delta ,
                          ~Omega[Ar]))),
                       breaks = seq(-3, 3, 0.5),
                       expand = c(0.05, 0.05)
                        ) +
  
    geom_smooth(aes (x=as.numeric(Month2),
                      y=dOme_MY, colour=Sub_region),
                span=0.8, se=F)+
      stat_summary(aes (x=as.numeric(Month2),
                      y=dOme_MY, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.2))+
    stat_summary(aes (x=as.numeric(Month2), 
                      y=dOme_MY, fill=Sub_region),
                 shape=21, size=1,
                fun.data = "mean_cl_boot", geom = "point",
                position=position_dodge(width=0.2))+
  facet_grid(Zone~.)

#DOmega_exp

om_delta_Y2<- DeltaYear_plot2+
    scale_y_continuous(#limits = c(-350,340),
                     expand = c(0.05, 0.05),
                     #breaks = seq(-800, 800, 50),
                      name=(expression (paste(Delta ,
                          ~Omega[Ar]))))+
    stat_summary(aes (x=Season, y=dAra_mean, fill=Sub_region),
                fun.data = "mean_cl_boot", geom = "bar",
                position=position_dodge(width=0.8))+
    stat_summary(aes (x=Season, y=dAra_mean, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.8))+
  theme(panel.spacing = unit(0.8, "lines"))
#om_delta_Y2

dOm_Y3<- DeltaYear_plot3+
   scale_y_continuous(#limits = c(-0.9, 1),
                     expand = c(0.02, 0.02),
                     breaks = seq(-5, 5, 0.5),
                     name=(expression (paste(Delta ,
                          ~Omega[Ar]))))+
    
   stat_summary(aes (x=Zone, y=dAra_mean, 
                     fill=Sub_region, shape=Zone),
                fun.data = "mean_cl_boot", geom = "point", 
                size=1.5, position=position_dodge(width=0.5))+
    stat_summary(aes (x=Zone, y=dAra_mean, colour=Sub_region),
                fun.data = "mean_cl_boot", 
                geom = "errorbar",   width = 0.2,
               position=position_dodge(width=0.5))
#dOm_Y3

- Figure 4: Seasonal Δ and yearly sums

Seasonality_deltas<-ggarrange(
          TA_delta_Y2 +theme(legend.position = "none",
                              axis.text.x=element_blank()),
          DIC_delta_Y2+theme(legend.position = "none",
                              strip.text.x = element_blank(),
                              axis.text.x=element_blank()), 
          pH_delta_Y2+theme(legend.position = "none",
                              strip.text.x = element_blank(),
                              axis.text.x=element_blank()), 
          om_delta_Y2+ theme(panel.spacing = unit(0.8, "lines"),
                              strip.text.x = element_blank()),
          #TA_DIC_sum,
          nrow = 4, 
          #labels = c("A", "B", " C"),
          heights =c(1, 0.9, 0.9, 1.2))
          #widths = c(1, 1, 0.9))
Seasonality_deltas

Seasonality_deltas3<-ggarrange(
          dTA_my3,
          dDIC_my3,
          dpH_my3,
          dOm_my3,
          nrow = 4, 
          #labels = c("A", "B", " C"),
          heights =c(1, 0.9, 0.9, 1))
Seasonality_deltas3

#ggsave(file="FLK_results/Figures/Fig_4/Fig_4_delta_season.svg", plot=Seasonality_deltas, dpi = 300, width=6, height=6)

#ggsave(file="FLK_results/Figures/Fig_4/Fig_4_delta_ICRS.svg", plot=Seasonality_deltas, dpi = 300, width=8, height=6)

#ggsave(file="FLK_results/Figures/Fig_4/Fig_4_delta_Summary.svg", plot=Seasonality_deltas3, dpi = 300, width=8, height=8)

Figure 4: Seasonal inshore-ocean gradients in the Florida Keys. (A) Seasonal ΔTA. (B) Seasonal ΔDIC. (C) Seasonal ΩAr. The bars represent the mean Δ values per season, region, and shelf position (± 95 CI).

5.4 Delta season values

- Delta season stats (all data)

  dSeason_Stats<- ddply (WS.reef, .(Zone, Sub_region, Season),
                            summarise,
                  dTA_mean = mean (dTA_MY, na.rm = T),
                  dTA_sd = sd (dTA_MY, na.rm = T),
                  
                  dnTA_mean = mean (dnTA_MY, na.rm = T),
                  dnTA_sd = sd (dnTA_MY, na.rm = T),
                 
                  dDIC_mean = mean (dDIC_MY, na.rm = T),
                  dDIC_sd = mean (dDIC_MY, na.rm = T),
                  
                  #dnDIC_mean = mean (dnDIC_MY, na.rm = T),
                  #dnDIC_sd = sd (dnDIC_MY, na.rm = T),
                  
                  #dpCO2_mean = mean (dpCO2_MY , na.rm = T),
                  #dpCO2_sd = sd (dpCO2_MY , na.rm = T),
                  
                  dpH_mean = mean (dpH_MY, na.rm = T),
                  dpH_sd = mean (dpH_MY, na.rm = T),
                  
                  dAra_mean = mean (dOme_MY , na.rm = T),
                  dAra_sd = mean (dOme_MY , na.rm = T),
                  n())

dSeason_Stats<-dSeason_Stats %>% 
 mutate_if(is.numeric, round, digits=3)
dSeason_Stats

- Delta season stats (monthly mean)

dSeasonal_Stats2<- ddply (dMonth_Stats,
                          .(Zone, Season, Sub_region),
                         summarise,

                  dTA_M = mean (dTA_mean, na.rm = T),
                  dTA_sd = sd (dTA_mean, na.rm = T),
                  dTA_se = std.error (dTA_mean, na.rm = T),
                  
                  dDIC_M = mean (dDIC_mean, na.rm = T),
                  dDIC_sd = sd (dDIC_mean, na.rm = T),
                  dDIC_se = std.error (dDIC_mean, na.rm = T),
                  
                  #dnTA_M = mean (dnTA_mean, na.rm = T),
                  #dnTA_sd = sd (dnTA_mean, na.rm = T),
                  
                  #dnDIC_M = mean (dnDIC_mean, na.rm = T),
                  #dnDIC_sd = sd (dnDIC_mean, na.rm = T),

                  dpCO2_M = mean (dpCO2_mean , na.rm = T),
                  dpCO2_sd = sd (dpCO2_mean , na.rm = T),
                  dpCO2_se = std.error (dpCO2_mean , na.rm = T),

                  dpH_M = mean (dpH_mean, na.rm = T),
                  dpH_sd = sd (dpH_mean, na.rm = T),
                  dpH_se = std.error (dpH_mean, na.rm = T),

                  dAra_M = mean (dAra_mean , na.rm = T),
                  dAra_sd = sd (dAra_mean , na.rm = T),
                  dAra_se = std.error (dAra_mean , na.rm = T),
                  n())

dSeasonal_Stats2<-dSeasonal_Stats2 %>% 
 mutate_if(is.numeric, round, digits=3)
dSeasonal_Stats2
#write.csv(dSeasonal_Stats2, "FLK_results/Table_2_SeasonDelta_B.csv", row.names = F)

Note: SD is NA when calculating it based on monthly meand (n=3 per season)

- Delta yearly stats (monthly mean)

dYearly_Stats<- ddply (dMonth_Stats, .(Zone, Sub_region),
                         summarise,

                  dTA_M = mean (dTA_mean, na.rm = T),
                  dTA_sd = sd (dTA_mean, na.rm = T),
                  #dTA_se = std.error (dTA_mean, na.rm = T),
                  
                  dDIC_M = mean (dDIC_mean, na.rm = T),
                  dDIC_sd = sd (dDIC_mean, na.rm = T),
                  #dDIC_se = std.error (dDIC_mean, na.rm = T),
                  
                  dnTA_M = mean (dnTA_mean, na.rm = T),
                  dnTA_sd = sd (dnTA_mean, na.rm = T),
                  
                  dnDIC_M = mean (dnDIC_mean, na.rm = T),
                  dnDIC_sd = sd (dnDIC_mean, na.rm = T),

                  dpCO2_M = mean (dpCO2_mean , na.rm = T),
                  dpCO2_sd = sd (dpCO2_mean , na.rm = T),
                  #dpCO2_se = std.error (dpCO2_mean , na.rm = T),

                  dpH_M = mean (dpH_mean, na.rm = T),
                  dpH_sd = sd (dpH_mean, na.rm = T),
                  #dpH_se = std.error (dpH_mean, na.rm = T),

                  dAra_M = mean (dAra_mean , na.rm = T),
                  dAra_sd = sd (dAra_mean , na.rm = T),
                  #dAra_se = std.error (dAra_mean , na.rm = T),
                  n())

dYearly_Stats<-dYearly_Stats %>% 
 mutate_if(is.numeric, round, digits=3)
dYearly_Stats
#write.csv(dYearly_Stats, "FLK_results/Table_1b_delta_year.csv", row.names = F)

- Yearly summ (monthly mean)

dYear_Add<- ddply (dMonth_Stats, .(Zone, Sub_region),
           summarise,
  su_dTA_Y = sum (dTA_mean, na.rm = T),
  #m_TA_Y = mean (dTA_mean, na.rm = T),
  #sd_TA_Y = sd (dTA_mean, na.rm = T),
  
  su_dDIC_Y = sum (dDIC_mean, na.rm = T),
  #m_dDIC_Y = mean (dDIC_mean, na.rm = T),
  #sd_dDIC_Y = sd (dDIC_mean, na.rm = T),
  

  su_dpCO2_Y = sum (dpCO2_mean, na.rm = T),
  #m_pCO2_Y = mean (dpCO2_mean, na.rm = T),
  #sd_pCO2_Y = sd (dpCO2_mean, na.rm = T),
  
  su_dpH_Y = sum (dpH_mean, na.rm = T),
  #m_pH_Y = mean (dpH_mean, na.rm = T),
  #sd_pH_Y = sd (dpH_mean, na.rm = T),
  
  su_dAra_Y = sum (dAra_mean, na.rm = T),
  #m_Ara_Y = mean (dAra_mean, na.rm = T),
  #sd_Ara_Y = sd (dAra_mean, na.rm = T),
  n())

dYear_Add<-dYear_Add %>% 
 mutate_if(is.numeric, round, digits=2)
dYear_Add
#write.csv(dYear_Add, "FLK_results/Table_1_year_byMM.csv", row.names = F)

- Yearly summ (indiviual years)

dYear_Add2<- ddply (WS.reef, .(Zone, Sub_region, MY, Region, Year),
                            summarise,
                  dTA_mean = mean (dTA_MY, na.rm = T),
                  dTA_sd = sd (dTA_MY, na.rm = T),
                  #dTA_se = std.error (dTA_MY, na.rm = T),
                  
                  dnTA_mean = mean (dnTA_MY, na.rm = T),
                  dnTA_sd = sd (dnTA_MY, na.rm = T),
                 
                  dDIC_mean = mean (dDIC_MY, na.rm = T),
                  dDIC_sd = mean (dDIC_MY, na.rm = T),
                  #dDIC_se = std.error (dDIC_MY, na.rm = T),
                  
                  dnDIC_mean = mean (dnDIC_MY, na.rm = T),
                  dnDIC_sd = sd (dnDIC_MY, na.rm = T),
                  
                  dpCO2_mean = mean (dpCO2_MY , na.rm = T),
                  dpCO2_sd = sd (dpCO2_MY , na.rm = T),
                  #dpCO2_se = std.error (dpCO2_MY, na.rm = T),
                  
                  dpH_mean = mean (dpH_MY, na.rm = T),
                  dpH_sd = mean (dpH_MY, na.rm = T),
                  #dPH_se = std.error (dpH_MY, na.rm = T),
                  
                  dAra_mean = mean (dOme_MY , na.rm = T),
                  dAra_sd = mean (dOme_MY , na.rm = T),
                  #dAra_se = std.error (dOme_MY, na.rm = T),
                  n())

dYear_Add2<-dYear_Add2 %>% 
 mutate_if(is.numeric, round, digits=3)
dYear_Add2
dYear_Add2<-dYear_Add2[dYear_Add2$Year>2014, ]
dYear_Add2<-dYear_Add2[dYear_Add2$Year<2022, ]

dYear_Add3<- ddply (dYear_Add2, .(Zone, Sub_region, Year),
           summarise,
  su_dTA_Y = sum (dTA_mean, na.rm = T),
  #m_TA_Y = mean (dTA_mean, na.rm = T),
  #sd_TA_Y = sd (dTA_mean, na.rm = T),
  
  su_dDIC_Y = sum (dDIC_mean, na.rm = T),
  #m_dDIC_Y = mean (dDIC_mean, na.rm = T),
  #sd_dDIC_Y = sd (dDIC_mean, na.rm = T),
  

  su_dpCO2_Y = sum (dpCO2_mean, na.rm = T),
  #m_pCO2_Y = mean (dpCO2_mean, na.rm = T),
  #sd_pCO2_Y = sd (dpCO2_mean, na.rm = T),
  
  su_dpH_Y = sum (dpH_mean, na.rm = T),
  #m_pH_Y = mean (dpH_mean, na.rm = T),
  #sd_pH_Y = sd (dpH_mean, na.rm = T),
  
  su_dAra_Y = sum (dAra_mean, na.rm = T),
  #m_Ara_Y = mean (dAra_mean, na.rm = T),
  #sd_Ara_Y = sd (dAra_mean, na.rm = T),
  n())

dYear_Add3<-dYear_Add3 %>% 
 mutate_if(is.numeric, round, digits=2)
dYear_Add3

5.5 Seasonal models

season.data<-WS.reef[WS.reef$Extreme=="Normal", ]
season.data<-droplevels(season.data)
season.data$Zone<-factor(season.data$Zone, levels = c("Offshore", "Mid channel", "Inshore"))
#summary(season.data)

inshore.season.data<-season.data[season.data$Zone=="Inshore", ]
midchanel.season.data<-season.data[season.data$Zone=="Mid channel", ]
ofshore.season.data<-season.data[season.data$Zone=="Offshore", ]

LMER - TA month

  hist(FLK.data_filtered$TA_umol_kg)

  shapiro.test(FLK.data_filtered$TA_umol_kg) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  FLK.data_filtered$TA_umol_kg
## W = 0.81653, p-value < 2.2e-16
# 
#   dTA_season<-lmer(dTA_MY~  Zone + Sub_region + Season +
#                            Zone:Sub_region + Zone:Season + Sub_region:Season+   
#                            (1|SiteID), data=season.data)
  
  TA_month_0<-lmer(TA_umol_kg~  Zone * Sub_region * Month +
                           (1|SiteID), data=FLK.data_filtered)
  #anova(TA_month_0)
  
  TA_month<-lmer(TA_umol_kg~  Zone + Sub_region + Month +
                              Zone:Sub_region + Zone:Month + Sub_region:Month +
                              (1|SiteID), data=season.data)
  
  #summary(dTA_season)    
  av.TA_month<-(anova(TA_month))
  av.TA_month
  ranova(TA_month)
  #step(TA_month)
  
  plot(TA_month)

  par(mfrow=c(1,2))
  qqnorm(resid(TA_month))
  acf(resid(TA_month), main="acf(resid(dTA Season))")

  par(mfrow=c(1,1))
  
  #summ(TA_month, scale = TRUE)
  #plot_summs(TA_month)
  
  TA_mo.emmc<-emmeans(TA_month, ~Zone*Month, by="Sub_region")
    TA_mon.emmc<-multcomp::cld(TA_mo.emmc)
    #dTA_ses.emmc<-as.data.frame(dTA_ses.emmc[complete.cases(dTA_ses.emmc),])
    #TA_mon.emmc<-TA_mon.emmc[order(TA_mon.emmc$Zone, TA_mon.emmc$Month), ]
  TA_mon.emmc

LMER - TA season

  hist(season.data$TA_umol_kg)

  shapiro.test(season.data$TA_umol_kg) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  season.data$TA_umol_kg
## W = 0.84701, p-value < 2.2e-16
# 
#   dTA_season<-lmer(dTA_MY~  Zone + Sub_region + Season +
#                            Zone:Sub_region + Zone:Season + Sub_region:Season+   
#                            (1|SiteID), data=season.data)
  
  TA_season_0<-lmer(TA_umol_kg~  Zone * Sub_region * Season +
                           (1|SiteID), data=season.data)
  anova(TA_season_0)
  TA_season<-lmer(TA_umol_kg~ Zone + Sub_region + Season +
                              Zone:Sub_region + 
                              Zone:Season + 
                              Sub_region:Season +
                              (1|SiteID), data=season.data)
  anova(TA_season_0, TA_season)
  #summary(av.TA_season)    
  av.TA_season<-(anova(TA_season))
  av.TA_season
  ranova(TA_season)
  #step(TA_season)
  
  plot(TA_season)

  par(mfrow=c(1,2))
  qqnorm(resid(TA_season))
  acf(resid(TA_season), main="acf(resid(TA Season))")

  par(mfrow=c(1,1))
  
  #summ(av.TA_season, scale = TRUE)
  #plot_summs(TA_season)
  
  TA_se.emmc<-emmeans(TA_season, ~Zone*Season, by="Sub_region")
    TA_seas.emmc<-multcomp::cld(TA_se.emmc)
    TA_seas.emmc
  TA_se.emmc2<-emmeans(TA_season, ~Sub_region*Season, by="Zone")
    TA_seas.emmc2<-multcomp::cld(TA_se.emmc2)
    TA_seas.emmc2

LMER - all dTA - MODEL 13

  hist(season.data$dTA_MY)

  shapiro.test(season.data$dTA_MY) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  season.data$dTA_MY
## W = 0.82647, p-value < 2.2e-16
# 
#   dTA_season<-lmer(dTA_MY~  Zone + Sub_region + Season +
#                            Zone:Sub_region + Zone:Season + Sub_region:Season+   
#                            (1|SiteID), data=season.data)
  
  dTA_season<-lmer(dTA_MY~  Zone * Sub_region * Season +
                           (1|SiteID), data=season.data)
  
  #summary(dTA_season)    
  av.dTA_season<-(anova(dTA_season))
  av.dTA_season
  ranova(dTA_season)
  #step(dTA_season)
  
  plot(dTA_season)

  par(mfrow=c(1,2))
  qqnorm(resid(dTA_season))
  acf(resid(dTA_season), main="acf(resid(dTA Season))")

  par(mfrow=c(1,1))
  
  #summ(dTA_season, scale = TRUE)
  #plot_summs(dTA_season)
 dTA_ses.emmc<-emmeans(dTA_season, ~Season*Sub_region, by="Zone")
    dTA_ses.emmc<-multcomp::cld(dTA_ses.emmc)
    #dTA_ses.emmc<-as.data.frame(dTA_ses.emmc[complete.cases(dTA_ses.emmc),])
    dTA_ses.emmc<-dTA_ses.emmc[order(dTA_ses.emmc$Zone, 
                                     dTA_ses.emmc$Season, 
                                     dTA_ses.emmc$Sub_region), ]
  dTA_ses.emmc
  dTA_ses.emmc[,-c(3)] %>% kable("html", digits=2, row.names = F,
                                 caption = "Seasonal dTA") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Offshore", 1, 16) %>% # groups rows with zone label
      pack_rows(., "Mid-Channel", 17, 32) %>%
      pack_rows(., "Inshore", 33, 48)
Seasonal dTA
Season Sub_region emmean SE df lower.CL upper.CL .group
Offshore
Winter BB 1.05 11.74 223.40 -22.10 24.19 1
Winter UK 3.89 10.07 257.16 -15.94 23.72 1
Winter MK 4.60 9.68 230.62 -14.47 23.66 1
Winter LK 1.94 8.31 220.73 -14.43 18.32 1
Spring BB -3.90 11.17 183.03 -25.93 18.13 1
Spring UK -1.98 9.51 214.78 -20.72 16.76 1
Spring MK -7.46 8.76 162.74 -24.76 9.84 1
Spring LK -11.50 7.54 157.14 -26.39 3.39 1
Summer BB -5.51 12.08 246.64 -29.30 18.28 1
Summer UK -4.77 10.28 277.89 -25.00 15.47 1
Summer MK -24.72 9.86 246.64 -44.14 -5.29 1
Summer LK -10.43 8.54 246.64 -27.26 6.39 1
Fall BB -0.83 10.90 170.54 -22.35 20.68 1
Fall UK -0.58 9.50 216.63 -19.31 18.15 1
Fall MK -1.32 8.76 162.74 -18.62 15.98 1
Fall LK -3.35 7.62 164.25 -18.40 11.69 1
Mid-Channel
Winter BB 8.02 12.08 246.64 -15.77 31.81 34
Winter UK 10.66 12.45 271.51 -13.86 35.17 34
Winter MK 25.24 9.68 230.62 6.17 44.31 4
Winter LK 13.55 8.90 171.14 -4.01 31.11 4
Spring BB -8.62 12.09 243.16 -32.43 15.19 234
Spring UK -3.03 11.74 223.36 -26.17 20.12 234
Spring MK -37.30 8.64 154.39 -54.36 -20.24 123
Spring LK -49.11 8.40 139.56 -65.72 -32.50 12
Summer BB -13.78 12.08 246.64 -37.57 10.01 234
Summer UK -5.58 12.87 297.18 -30.91 19.74 234
Summer MK -73.30 9.86 246.64 -92.72 -53.87 1
Summer LK -76.55 9.86 246.64 -95.97 -57.12 1
Fall BB 4.06 11.16 186.76 -17.94 26.07 34
Fall UK 0.63 11.74 223.36 -22.52 23.77 234
Fall MK 7.17 8.89 172.13 -10.39 24.72 4
Fall LK -11.66 8.52 146.93 -28.49 5.17 234
Inshore
Winter BB 40.60 11.74 223.41 17.45 63.74 67
Winter UK 48.74 10.51 298.97 28.07 69.41 67
Winter MK 57.00 10.27 281.16 36.77 77.22 7
Winter LK 7.36 9.19 189.81 -10.77 25.48 56
Spring BB -62.57 11.17 183.07 -84.61 -40.54 34
Spring UK -57.07 9.86 246.64 -76.50 -37.64 34
Spring MK -80.92 8.40 139.55 -97.53 -64.31 3
Spring LK -124.49 8.29 132.95 -140.89 -108.09 2
Summer BB -46.25 12.08 246.64 -70.04 -22.45 34
Summer UK -35.23 9.86 246.64 -54.66 -15.81 45
Summer MK -148.77 10.06 262.68 -168.58 -128.95 12
Summer LK -183.91 10.27 281.21 -204.14 -163.69 1
Fall BB 26.25 10.65 158.44 5.20 47.29 67
Fall UK 44.42 9.86 246.64 24.99 63.85 67
Fall MK 16.80 8.90 171.08 -0.77 34.36 67
Fall LK -63.22 8.52 146.93 -80.05 -46.39 34
  dTA_year.emmc<-emmeans(dTA_season, ~Sub_region*Zone)
    dTA_year.emmc<-multcomp::cld(dTA_year.emmc)
    #dTA_ses.emmc<-as.data.frame(dTA_ses.emmc[complete.cases(dTA_ses.emmc),])
    dTA_year.emmc<-dTA_year.emmc[order(dTA_year.emmc$Zone, 
                                      dTA_year.emmc$Sub_region), ]
  #dTA_year.emmc
  
  dTA_year.emmc[,-c(2)] %>% kable("html", digits=2, row.names = F,
                                  caption = "Year dTA") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Offshore", 1, 4) %>% # groups rows with zone label
      pack_rows(., "Mid-Channel", 5, 8) %>%
      pack_rows(., "Inshore", 9, 12)
Year dTA
Sub_region emmean SE df lower.CL upper.CL .group
Offshore
BB -2.30 6.34 21.07 -15.49 10.89 34
UK -0.86 5.39 24.81 -11.97 10.25 4
MK -7.23 5.13 20.50 -17.92 3.47 34
LK -5.84 4.44 20.23 -15.09 3.41 4
Mid-Channel
BB -2.58 6.51 23.52 -16.03 10.88 34
UK 0.67 6.67 25.91 -13.05 14.39 4
MK -19.55 5.14 20.51 -30.24 -8.85 234
LK -30.94 4.98 18.14 -41.40 -20.49 23
Inshore
BB -10.49 6.32 20.76 -23.64 2.65 234
UK 0.21 5.47 26.46 -11.03 11.46 4
MK -38.97 5.21 21.68 -49.78 -28.17 2
LK -91.07 5.05 19.19 -101.64 -80.49 1

Figure 4A: Model

dTA_ses_2.emmc<-as.data.frame(dTA_ses.emmc)
dTA_ye_3.emmc<-as.data.frame(dTA_year.emmc)
dTA_ye_3.emmc$Season<-"Mean"

dTA_all_4<-rbind(dTA_ses_2.emmc, dTA_ye_3.emmc)
dTA_all_4$Zone<-factor(dTA_all_4$Zone, 
                          levels=c("Inshore" , "Mid channel", "Offshore"))


DeltaYearTA<- ggplot(dTA_all_4, aes(x=Season, y=emmean, fill=Sub_region)) +
        MyTheme +  
        #facet_grid(Zone~., scales = "free_y")+
        facet_grid(~Zone, scales="free" )+
        geom_hline(yintercept = 0, color="gray")+
        theme(axis.title.x = element_blank(),
              legend.position = "bottom",
              axis.text.x = element_text(angle = 0))+

    scale_y_continuous(#limits = c(-350,340),
                     expand = c(0.03, 0.03),
                     #breaks = seq(-800, 800, 50),
                     name=expression(paste(Delta, "TA  (", mu, "mol ", ~kg^-1, ")")))+
    geom_bar(position = "dodge", color="black", 
           stat = "summary",
           fun = "mean")+
  geom_errorbar(aes(ymin=emmean-SE, ymax=emmean+SE), width=0.2,
                 position=position_dodge(.9)) 
DeltaYearTA

LMER - dTA Inshore

# Inshore dTA
  hist(inshore.season.data$dTA_MY)

  shapiro.test(inshore.season.data$dTA_MY) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  inshore.season.data$dTA_MY
## W = 0.9743, p-value = 1.971e-06
  dTA_season_in<-lmer(dTA_MY~  Sub_region * Season +
                           (1|SiteID), data=inshore.season.data)
  
  #summary(dTA_season_in)    
  av.dTA_season_in<-anova(dTA_season_in)
  av.dTA_season_in
  ranova(dTA_season_in)
  #step(dTA_season_in)
  
  plot(dTA_season_in)

  par(mfrow=c(1,2))
  qqnorm(resid(dTA_season_in))
  acf(resid(dTA_season_in), main="acf(resid(dTA Season))")

  par(mfrow=c(1,1))
  #summ(dTA_season_in, scale = TRUE)
  #plot_summs(dTA_season_in)
  
  dTA_ses_in.emmc<-emmeans(dTA_season_in, ~ Sub_region*Season)
    dTA_ses_in.emmc<-multcomp::cld(dTA_ses_in.emmc)
    #dTA_ses_in.emmc<-as.data.frame(dTA_ses_in.emmc[complete.cases(dTA_ses_in.emmc),])
    dTA_ses_in.emmc<-dTA_ses_in.emmc[order(dTA_ses_in.emmc$Season,
                                           dTA_ses_in.emmc$Sub_region), ]
  dTA_ses_in.emmc

LMER - DIC season

  hist(season.data$DIC_umol_kg)

  shapiro.test(season.data$DIC_umol_kg) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  season.data$DIC_umol_kg
## W = 0.91454, p-value < 2.2e-16
  DIC_season_0<-lmer(DIC_umol_kg~  Zone * Sub_region * Season +
                           (1|SiteID), data=season.data)
  

  #summary(DIC_season_0)    
  av.DIC_season<-(anova(DIC_season_0))
  av.DIC_season
  ranova(DIC_season_0)
  #step(DIC_season_0)
  
  plot(DIC_season_0)

  par(mfrow=c(1,2))
  qqnorm(resid(DIC_season_0))
  acf(resid(DIC_season_0), main="acf(resid(DIC Season))")

  par(mfrow=c(1,1))
  
  #summ(av.TA_season, scale = TRUE)
  #plot_summs(av.DIC_season)
  
  DIC_se.emmc<-emmeans(DIC_season_0, ~Zone*Season, by="Sub_region")
    DIC_seas.emmc<-multcomp::cld(DIC_se.emmc)
    DIC_seas.emmc
  DIC_se.emmc2<-emmeans(DIC_season_0, ~Sub_region*Season, by="Zone")
    DIC_seas.emmc2<-multcomp::cld(TA_se.emmc2)
    DIC_seas.emmc2

LMER - all dDIC - MODEL 14

# Inshore Omega
  hist(season.data$dDIC_MY)

  shapiro.test(season.data$dDIC_MY) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  season.data$dDIC_MY
## W = 0.87909, p-value < 2.2e-16
  # dDIC_season<-lmer(dDIC_MY~ Zone + Sub_region + Season +
  #                          Zone:Sub_region + Zone:Season + Sub_region:Season+   
  #                          (1|SiteID), data=season.data)
  
  dDIC_season<-lmer(dDIC_MY~ Zone * Sub_region * Season +
                           (1|SiteID), data=season.data)
  
  #summary(dDIC_season)    
  av.dDIC_season<-anova(dDIC_season)
  av.dDIC_season
  ranova(dDIC_season)
  step(dDIC_season)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik   AIC    LRT Df Pr(>Chisq)  
## <none>                    50 -6071.5 12243                       
## (1 | SiteID)          0   49 -6074.0 12246 5.0185  1    0.02508 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                        Eliminated Sum Sq Mean Sq NumDF  DenDF F value   Pr(>F)
## Zone:Sub_region:Season          0 102157  5675.4    18 1113.1  2.4361 0.000722
##                           
## Zone:Sub_region:Season ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## dDIC_MY ~ Zone * Sub_region * Season + (1 | SiteID)
  plot(dDIC_season)

  par(mfrow=c(1,2))
  qqnorm(resid(dDIC_season))
  acf(resid(dDIC_season), main="acf(resid(dTA Season))")

  par(mfrow=c(1,1))
  #summ(dDIC_season, scale = TRUE)
  #plot_summs(dDIC_season)
  
 dDIC_ses.emmc<-emmeans(dDIC_season, ~Season*Sub_region, by="Zone")
    dDIC_ses.emmc<-multcomp::cld(dDIC_ses.emmc)
    #dDIC_ses.emmc<-as.data.frame(dDIC_ses.emmc[complete.cases(dDIC_ses.emmc),])
    dDIC_ses.emmc<-dDIC_ses.emmc[order(dDIC_ses.emmc$Zone, 
                                     dDIC_ses.emmc$Season, 
                                     dDIC_ses.emmc$Sub_region), ]
  #dDIC_ses.emmc

  dDIC_ses.emmc[,-c(3)] %>% kable("html", digits=2, row.names = F,
                                 caption = "Seasonal dDIC") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Offshore", 1, 16) %>% # groups rows with zone label
      pack_rows(., "Mid-Channel", 17, 32) %>%
      pack_rows(., "Inshore", 33, 48)
Seasonal dDIC
Season Sub_region emmean SE df lower.CL upper.CL .group
Offshore
Winter BB -1.15 12.79 151.53 -26.42 24.11 1
Winter UK -0.09 10.92 175.49 -21.64 21.47 1
Winter MK 7.93 10.53 156.21 -12.87 28.73 1
Winter LK 7.32 8.84 138.04 -10.16 24.79 1
Spring BB -0.53 12.23 126.75 -24.73 23.67 1
Spring UK -1.51 10.36 146.50 -21.99 18.97 1
Spring MK -13.60 9.63 112.46 -32.69 5.48 1
Spring LK -6.09 8.29 109.38 -22.52 10.35 1
Summer BB 5.88 13.12 166.46 -20.02 31.78 1
Summer UK -2.98 11.12 188.57 -24.92 18.96 1
Summer MK -20.44 10.71 166.46 -41.58 0.71 1
Summer LK 0.35 9.67 193.08 -18.73 19.43 1
Fall BB 3.55 11.96 117.87 -20.14 27.24 1
Fall UK 2.73 10.36 147.09 -17.73 23.20 1
Fall MK 0.39 9.63 112.46 -18.70 19.47 1
Fall LK 1.17 8.37 113.66 -15.41 17.76 1
Mid-Channel
Winter BB 10.65 13.12 166.46 -15.25 36.55 45
Winter UK 1.74 13.48 183.28 -24.87 28.34 345
Winter MK 24.46 10.53 156.21 3.66 45.26 45
Winter LK 31.79 9.77 118.05 12.45 51.13 5
Spring BB -21.90 13.13 165.36 -47.82 4.02 12345
Spring UK -29.06 12.79 151.50 -54.33 -3.79 1234
Spring MK -65.71 9.51 107.15 -84.57 -46.86 1
Spring LK -53.48 9.28 97.74 -71.90 -35.06 123
Summer BB 4.03 13.12 166.46 -21.87 29.92 45
Summer UK -3.00 13.90 201.96 -30.41 24.41 2345
Summer MK -59.92 10.71 166.46 -81.07 -38.78 12
Summer LK -57.79 11.12 189.74 -79.72 -35.86 123
Fall BB 22.16 12.21 127.83 -2.00 46.33 45
Fall UK 15.78 12.79 151.50 -9.49 41.04 45
Fall MK 22.59 9.76 118.32 3.26 41.92 45
Fall LK 5.03 9.39 102.32 -13.60 23.66 45
Inshore
Winter BB 46.86 12.79 151.53 21.60 72.13 345
Winter UK 43.10 11.35 202.57 20.72 65.47 34
Winter MK 55.50 11.12 189.71 33.57 77.43 45
Winter LK 27.84 10.05 130.68 7.96 47.73 34
Spring BB -90.97 12.23 126.78 -115.16 -66.77 1
Spring UK -125.12 10.71 166.46 -146.26 -103.98 1
Spring MK -130.41 9.28 97.73 -148.83 -111.98 1
Spring LK -131.64 9.18 93.55 -149.86 -113.42 1
Summer BB -10.42 13.12 166.46 -36.31 15.48 23
Summer UK -25.40 10.71 166.46 -46.55 -4.26 2
Summer MK -122.39 10.91 177.35 -143.91 -100.86 1
Summer LK -112.23 11.58 218.92 -135.06 -89.40 1
Fall BB 73.29 11.72 109.74 50.06 96.52 45
Fall UK 96.30 10.71 166.46 75.16 117.44 5
Fall MK 50.25 9.77 118.03 30.92 69.59 45
Fall LK -7.47 9.39 102.32 -26.10 11.16 23
  dDIC_year.emmc<-emmeans(dDIC_season, ~Sub_region*Zone)
    dDIC_year.emmc<-multcomp::cld(dDIC_year.emmc)
    #dTA_ses.emmc<-as.data.frame(dTA_ses.emmc[complete.cases(dTA_ses.emmc),])
    dDIC_year.emmc<-dDIC_year.emmc[order(dDIC_year.emmc$Zone, 
                                      dDIC_year.emmc$Sub_region), ]
  #dDIC_year.emmc
  
  dDIC_year.emmc[,-c(2)] %>% kable("html", digits=2, row.names = F,
                                  caption = "Year dDIC") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Offshore", 1, 4) %>% # groups rows with zone label
      pack_rows(., "Mid-Channel", 5, 8) %>%
      pack_rows(., "Inshore", 9, 12)
Year dDIC
Sub_region emmean SE df lower.CL upper.CL .group
Offshore
BB 1.94 7.69 20.95 -14.06 17.93 3
UK -0.46 6.47 23.60 -13.82 12.90 3
MK -6.43 6.24 20.49 -19.42 6.56 23
LK 0.69 5.42 20.64 -10.59 11.97 3
Mid-Channel
BB 3.73 7.84 22.67 -12.50 19.96 3
UK -3.64 7.98 24.37 -20.10 12.83 23
MK -19.65 6.24 20.50 -32.64 -6.65 23
LK -18.61 6.15 19.32 -31.47 -5.76 23
Inshore
BB 4.69 7.67 20.71 -11.27 20.65 3
UK -2.78 6.54 24.73 -16.26 10.70 3
MK -36.76 6.30 21.34 -49.85 -23.67 12
LK -55.87 6.22 20.24 -68.84 -42.91 1

Figure 4B: Model

dDIC_ses_2.emmc<-as.data.frame(dDIC_ses.emmc)
dDIC_ye_3.emmc<-as.data.frame(dDIC_year.emmc)
dDIC_ye_3.emmc$Season<-"Mean"

dDIC_all_4<-rbind(dDIC_ses_2.emmc, dDIC_ye_3.emmc)
dDIC_all_4$Zone<-factor(dDIC_all_4$Zone, 
                          levels=c("Inshore" , "Mid channel", "Offshore"))


DeltaYearDIC<- ggplot(dDIC_all_4, aes(x=Season, y=emmean, fill=Sub_region)) +
        MyTheme +  
        #facet_grid(Zone~., scales = "free_y")+
        facet_grid(~Zone, scales="free" )+
        geom_hline(yintercept = 0, color="gray")+
        theme(axis.title.x = element_blank(),
              legend.position = "bottom",
              axis.text.x = element_text(angle = 0))+

    scale_y_continuous(#limits = c(-350,340),
                     expand = c(0.03, 0.03),
                     #breaks = seq(-800, 800, 50),
                     name=expression(paste(Delta, "DIC  (", mu, "mol ", ~kg^-1, ")")))+
    geom_bar(position = "dodge", color="black", 
           stat = "summary",
           fun = "mean")+
  geom_errorbar(aes(ymin=emmean-SE, ymax=emmean+SE), width=0.2,
                 position=position_dodge(.9)) 
DeltaYearDIC

LMER - dDIC Inshore

# Inshore dDIC
  hist(inshore.season.data$dDIC_MY)

  shapiro.test(inshore.season.data$dDIC_MY) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  inshore.season.data$dDIC_MY
## W = 0.99486, p-value = 0.2191
  dDIC_season_in<-lmer(dDIC_MY~  Sub_region * Season +
                           (1|SiteID), data=inshore.season.data)
  
  #summary(dDIC_season_in)    
  av.dDIC_season_in<-anova(dDIC_season_in)
  av.dDIC_season_in
  ranova(dDIC_season_in)
  #step(dDIC_season_in)
  
  plot(dDIC_season_in)

  par(mfrow=c(1,1))
  qqnorm(resid(dDIC_season_in))

  acf(resid(dDIC_season_in), main="acf(resid(dTA Season))")

  par(mfrow=c(1,1))
  #summ(dDIC_season_in, scale = TRUE)
  #plot_summs(dDIC_season_in)
  
  dDIC_ses_in.emmc<-emmeans(dDIC_season_in, ~ Sub_region*Season)
    dDIC_ses_in.emmc<-multcomp::cld(dDIC_ses_in.emmc)
    #dDIC_ses_in.emmc<-as.data.frame(dDIC_ses_in.emmc[complete.cases(dDIC_ses_in.emmc),])
    dDIC_ses_in.emmc<-dDIC_ses_in.emmc[order(dDIC_ses_in.emmc$Season,
                                           dDIC_ses_in.emmc$Sub_region), ]
  dDIC_ses_in.emmc

LMER - all dpCO2

# Inshore Omega
  hist(season.data$dpCO2_MY)

  shapiro.test(season.data$dpCO2_MY) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  season.data$dpCO2_MY
## W = 0.91489, p-value < 2.2e-16
  # dpCO2_season<-lmer(dpCO2_MY~ Zone + Sub_region + Season +
  #                          Zone:Sub_region + Zone:Season + Sub_region:Season+   
  #                          (1|SiteID), data=season.data)
  dpCO2_season<-lmer(dpCO2_MY~ Zone * Sub_region * Season +
                           (1|SiteID), data=season.data)
  
  #summary(dpCO2_season)    
  av.dPCO2_season<-anova(dpCO2_season)
  av.dPCO2_season
  ranova(dpCO2_season)
  step(dpCO2_season)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik   AIC    LRT Df Pr(>Chisq)  
## <none>                    50 -6083.0 12266                       
## (1 | SiteID)          0   49 -6086.3 12271 6.5586  1    0.01044 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                        Eliminated Sum Sq Mean Sq NumDF   DenDF F value
## Zone:Sub_region:Season          1  64511    3584    18 1109.73  1.4821
## Zone:Sub_region                 2  15206    2534     6   21.57  1.0401
## Zone:Season                     0 610146  101691     6 1129.41 41.7412
## Sub_region:Season               0  69763    7751     9 1128.46  3.1818
##                           Pr(>F)    
## Zone:Sub_region:Season 0.0877942 .  
## Zone:Sub_region        0.4272177    
## Zone:Season            < 2.2e-16 ***
## Sub_region:Season      0.0008284 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## dpCO2_MY ~ Zone + Sub_region + Season + (1 | SiteID) + Zone:Season + Sub_region:Season
  plot(dpCO2_season)

  par(mfrow=c(1,2))
  qqnorm(resid(dpCO2_season))
  acf(resid(dpCO2_season), main="acf(resid(dTA Season))")

  par(mfrow=c(1,1))
  #plot_summs(dpCO2_season)  
  
  dpCO2_ses.emmc<-emmeans(dpCO2_season, ~Zone*Sub_region*Season)
    dpCO2_ses.emmc<-multcomp::cld(dpCO2_ses.emmc)
    #dpCO2_ses.emmc<-as.data.frame(dpCO2_ses.emmc[complete.cases(dpCO2_ses.emmc),])
    dpCO2_ses.emmc<-dpCO2_ses.emmc[order(dpCO2_ses.emmc$Zone, dpCO2_ses.emmc$Season), ]
  dpCO2_ses.emmc
  #summ(dpCO2_season, scale = TRUE)

LMER - dpCO2 Inshore

# Inshore dDIC
  hist(inshore.season.data$dpCO2_MY)

  shapiro.test(inshore.season.data$dpCO2_MY) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  inshore.season.data$dpCO2_MY
## W = 0.98334, p-value = 0.0001773
  dpCO2_season_in<-lmer(dpCO2_MY~  Sub_region * Season +
                           (1|SiteID), data=inshore.season.data)
  
  #summary(dpCO2_season_in)    
  av.dPCO2_season_in<-anova(dpCO2_season_in)
  av.dPCO2_season_in
  ranova(dpCO2_season_in)
  #step(dpCO2_season_in)
  
  plot(dpCO2_season_in)

  par(mfrow=c(1,2))
  qqnorm(resid(dpCO2_season_in))
  acf(resid(dpCO2_season_in), main="acf(resid(dTA Season))")

  par(mfrow=c(1,1))
  #summ(dpCO2_season_in, scale = TRUE)
  #plot_summs(dpCO2_season_in)
  
  dpCO2_ses_in.emmc<-emmeans(dpCO2_season_in, ~ Sub_region*Season)
    dpCO2_ses_in.emmc<-multcomp::cld(dpCO2_ses_in.emmc)
    #dpCO2_ses_in.emmc<-as.data.frame(dpCO2_ses_in.emmc[complete.cases(dpCO2_ses_in.emmc),])
    dpCO2_ses_in.emmc<-dpCO2_ses_in.emmc[order(dpCO2_ses_in.emmc$Season,
                                           dpCO2_ses_in.emmc$Sub_region), ]
  dpCO2_ses_in.emmc

LMER - all Omega

# Inshore Omega
  hist(season.data$Aragonite_Sat_W)

  shapiro.test(season.data$Aragonite_Sat_W) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  season.data$Aragonite_Sat_W
## W = 0.97667, p-value = 6.107e-13
  # Omega_season<-lmer(Aragonite_Sat_W~  Zone + Sub_region + Season +
  #                          Zone:Sub_region + Zone:Season + Sub_region:Season+   
  #                          (1|SiteID), data=season.data)
  Omega_season<-lmer(Aragonite_Sat_W~  Zone * Sub_region * Season +
                           (1|SiteID), data=season.data)
  
  #summary(Omega_season)    
  av.Ome_season<-anova(Omega_season)
  av.Ome_season
  ranova(Omega_season)
  #step(Omega_season)
  
  plot(Omega_season)

  par(mfrow=c(1,2))
  qqnorm(resid(Omega_season))
  acf(resid(Omega_season), main="acf(resid(dTA Season))")

  par(mfrow=c(1,1))
  #plot_summs(Omega_season)  
    
  # Ara_ses.emmc<-emmeans(Omega_season, ~Zone*Sub_region*Season)
  #   Ara_ses.emmc<-multcomp::cld(Ara_ses.emmc)
  #   Ara_ses.emmc<-as.data.frame(Ara_ses.emmc[complete.cases(Ara_ses.emmc),])
  #   Ara_ses.emmc<-Ara_ses.emmc[order(Ara_ses.emmc$Zone, Ara_ses.emmc$Season), ]
  # Ara_ses.emmc
  
  Ara_ses.emmc<-emmeans(Omega_season, ~Zone*Season, by="Sub_region")
    Ara_ses.emmc<-multcomp::cld(Ara_ses.emmc)
    Ara_ses.emmc
  Ara_ses.emmc2<-emmeans(Omega_season, ~Sub_region*Season, by="Zone")
    Ara_ses.emmc2<-multcomp::cld(Ara_ses.emmc2)
    Ara_ses.emmc2

LMER - all dOmega - MODEL 16

# Inshore Omega
  hist(season.data$dOme_MY)

  shapiro.test(season.data$dOme_MY) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  season.data$dOme_MY
## W = 0.94836, p-value < 2.2e-16
  # Omega_season<-lmer(Aragonite_Sat_W~  Zone + Sub_region + Season +
  #                          Zone:Sub_region + Zone:Season + Sub_region:Season+   
  #                          (1|SiteID), data=season.data)
  dOmega_season<-lmer(dOme_MY~  Zone * Sub_region * Season +
                           (1|SiteID), data=season.data)
  
  #summary(dOmega_season)    
  av.dOme_season<-anova(dOmega_season)
  av.dOme_season
  ranova(dOmega_season)
  #step(dOmega_season)
  
  plot(dOmega_season)

  par(mfrow=c(1,2))
  qqnorm(resid(dOmega_season))
  acf(resid(dOmega_season), main="acf(resid(dTA Season))")

  par(mfrow=c(1,1))
  #plot_summs(dOmega_season)  
    
dAra_ses.emmc<-emmeans(dOmega_season, ~Zone*Season, by="Sub_region")
    dAra_ses.emmc<-multcomp::cld(dAra_ses.emmc)
    dAra_ses.emmc
dAra_ses.emmc1<-emmeans(dOmega_season, ~Sub_region*Season, by="Zone")
    dAra_ses.emmc1<-multcomp::cld(dAra_ses.emmc1)
    dAra_ses.emmc1
dAra_ses.emmc2<-emmeans(dOmega_season, ~Season*Sub_region, by="Zone")
    dAra_ses.emmc2<-multcomp::cld(dAra_ses.emmc2)
    #dTA_ses.emmc<-as.data.frame(dTA_ses.emmc[complete.cases(dTA_ses.emmc),])
    dAra_ses.emmc2<-dAra_ses.emmc2[order(dAra_ses.emmc2$Zone, 
                                     dAra_ses.emmc2$Season, 
                                     dAra_ses.emmc2$Sub_region), ]

dAra_ses.emmc2[,-c(3)] %>% kable("html", digits=2, row.names = F,
                                 caption = "Seasonal d Omega") %>%
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Offshore", 1, 16) %>% # groups rows with zone label
      pack_rows(., "Mid-Channel", 17, 32) %>%
      pack_rows(., "Inshore", 33, 48)
Seasonal d Omega
Season Sub_region emmean SE df lower.CL upper.CL .group
Offshore
Winter BB 0.02 0.07 188.90 -0.12 0.16 1
Winter UK 0.04 0.06 218.36 -0.08 0.16 1
Winter MK -0.04 0.06 194.94 -0.16 0.07 1
Winter LK -0.07 0.05 187.22 -0.17 0.03 1
Spring BB -0.04 0.07 156.03 -0.17 0.10 1
Spring UK -0.01 0.06 182.03 -0.12 0.11 1
Spring MK 0.06 0.05 138.40 -0.05 0.17 1
Spring LK -0.06 0.05 134.05 -0.16 0.03 1
Summer BB -0.13 0.07 208.26 -0.27 0.02 1
Summer UK -0.03 0.06 235.49 -0.15 0.10 1
Summer MK -0.07 0.06 208.26 -0.19 0.05 1
Summer LK -0.15 0.05 241.97 -0.26 -0.04 1
Fall BB -0.05 0.07 145.13 -0.18 0.08 1
Fall UK -0.04 0.06 183.21 -0.15 0.08 1
Fall MK -0.02 0.05 138.40 -0.13 0.09 1
Fall LK -0.06 0.05 139.79 -0.15 0.04 1
Mid-Channel
Winter BB -0.04 0.07 208.26 -0.19 0.10 12345
Winter UK 0.08 0.08 229.47 -0.07 0.23 2345
Winter MK 0.00 0.06 194.94 -0.12 0.11 234
Winter LK -0.19 0.05 145.50 -0.30 -0.08 12
Spring BB 0.13 0.07 206.04 -0.01 0.28 345
Spring UK 0.27 0.07 188.86 0.13 0.41 45
Spring MK 0.27 0.05 131.50 0.17 0.38 5
Spring LK 0.02 0.05 119.26 -0.09 0.12 2345
Summer BB -0.21 0.07 208.26 -0.36 -0.07 12
Summer UK -0.03 0.08 252.17 -0.18 0.13 12345
Summer MK -0.20 0.06 208.26 -0.32 -0.08 123
Summer LK -0.32 0.06 237.70 -0.44 -0.19 1
Fall BB -0.20 0.07 158.32 -0.34 -0.07 12
Fall UK -0.17 0.07 188.86 -0.31 -0.02 123
Fall MK -0.17 0.05 146.09 -0.28 -0.06 123
Fall LK -0.19 0.05 125.28 -0.29 -0.09 12
Inshore
Winter BB -0.06 0.07 188.91 -0.20 0.08 567
Winter UK 0.05 0.06 253.35 -0.08 0.17 67
Winter MK 0.03 0.06 237.66 -0.10 0.15 67
Winter LK -0.24 0.06 161.40 -0.35 -0.13 3456
Spring BB 0.24 0.07 156.06 0.11 0.38 78
Spring UK 0.65 0.06 208.26 0.53 0.77 9
Spring MK 0.44 0.05 119.25 0.34 0.55 89
Spring LK -0.01 0.05 113.80 -0.11 0.09 67
Summer BB -0.41 0.07 208.26 -0.55 -0.26 234
Summer UK -0.12 0.06 208.26 -0.24 0.00 456
Summer MK -0.41 0.06 221.97 -0.53 -0.29 234
Summer LK -0.80 0.07 274.41 -0.93 -0.67 1
Fall BB -0.48 0.07 134.85 -0.61 -0.35 123
Fall UK -0.52 0.06 208.26 -0.64 -0.40 123
Fall MK -0.35 0.05 145.46 -0.46 -0.24 345
Fall LK -0.65 0.05 125.28 -0.75 -0.54 12
dOm_year.emmc<-emmeans(dOmega_season, ~Sub_region*Zone)
    dOm_year.emmc<-multcomp::cld(dOm_year.emmc)
    #dTA_ses.emmc<-as.data.frame(dTA_ses.emmc[complete.cases(dTA_ses.emmc),])
    dOm_year.emmc<-dOm_year.emmc[order(dOm_year.emmc$Zone, 
                                      dOm_year.emmc$Sub_region), ]
  #dDIC_year.emmc
  
  dOm_year.emmc[,-c(2)] %>% kable("html", digits=2, row.names = F,
                                  caption = "Year d Omega") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Offshore", 1, 4) %>% # groups rows with zone label
      pack_rows(., "Mid-Channel", 5, 8) %>%
      pack_rows(., "Inshore", 9, 12)
Year d Omega
Sub_region emmean SE df lower.CL upper.CL .group
Offshore
BB -0.05 0.04 20.88 -0.13 0.04 234
UK -0.01 0.03 24.10 -0.08 0.06 234
MK -0.02 0.03 20.35 -0.09 0.05 234
LK -0.08 0.03 20.92 -0.14 -0.02 234
Mid-Channel
BB -0.08 0.04 22.98 -0.17 0.01 234
UK 0.04 0.04 25.04 -0.05 0.13 4
MK -0.02 0.03 20.37 -0.09 0.04 234
LK -0.17 0.03 18.97 -0.24 -0.10 2
Inshore
BB -0.18 0.04 20.60 -0.26 -0.09 23
UK 0.01 0.03 25.50 -0.06 0.09 34
MK -0.07 0.03 21.38 -0.14 0.00 234
LK -0.42 0.03 20.05 -0.49 -0.36 1

Figure 4D: Model

dAra_ses_2.emmc<-as.data.frame(dAra_ses.emmc2)
dAra_ye_3.emmc<-as.data.frame(dOm_year.emmc)
dAra_ye_3.emmc$Season<-"Mean"

dAra_all_4<-rbind(dAra_ses_2.emmc, dAra_ye_3.emmc)
dAra_all_4$Zone<-factor(dDIC_all_4$Zone, 
                          levels=c("Inshore" , "Mid channel", "Offshore"))


DeltaYearAra<- ggplot(dAra_all_4, aes(x=Season, y=emmean, fill=Sub_region)) +
        MyTheme +  
        #facet_grid(Zone~., scales = "free_y")+
        facet_grid(~Zone, scales="free" )+
        geom_hline(yintercept = 0, color="gray")+
        theme(axis.title.x = element_blank(),
              legend.position = "bottom",
              axis.text.x = element_text(angle = 0))+

    scale_y_continuous(#limits = c(-350,340),
                     expand = c(0.03, 0.03),
                     breaks = seq(-6, 6, 0.3),
                     name=(expression (paste(Delta ,
                          ~Omega[Ar]))))+
    geom_bar(position = "dodge", color="black", 
           stat = "summary",
           fun = "mean")+
  geom_errorbar(aes(ymin=emmean-SE, ymax=emmean+SE), width=0.2,
                 position=position_dodge(.9)) 

DeltaYearAra

LMER - Omega Inshore

# Inshore dOmega
  hist(inshore.season.data$Aragonite_Sat_W)

  shapiro.test(inshore.season.data$Aragonite_Sat_W) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  inshore.season.data$Aragonite_Sat_W
## W = 0.9897, p-value = 0.006908
  Omega_season_in<-lmer(Aragonite_Sat_W~  Sub_region * Season +
                           (1|SiteID), data=inshore.season.data)
  
      #summary(Omega_season_in)    
      av.Ome_season_in<-anova(Omega_season_in)
      av.Ome_season_in
      ranova(Omega_season_in)
      #step(Omega_season_in)
      
      plot(Omega_season_in)

      par(mfrow=c(1,2))
      qqnorm(resid(Omega_season_in))
      acf(resid(Omega_season_in), main="acf(resid(dTA Season))")

      par(mfrow=c(1,1))
      #summ(dDIC_season_in, scale = TRUE)
  #plot_summs(Omega_season_in)
  
  omega_ses_in.emmc<-emmeans(Omega_season_in, ~ Sub_region*Season)
    omega_ses_in.emmc<-multcomp::cld(omega_ses_in.emmc)
    #omega_ses_in.emmc<-as.data.frame(omega_ses_in.emmc[complete.cases(omega_ses_in.emmc),])
    omega_ses_in.emmc<-omega_ses_in.emmc[order(omega_ses_in.emmc$Season,
                                           omega_ses_in.emmc$Sub_region), ]
  omega_ses_in.emmc

LMER - all pH

# Inshore Omega
  hist(season.data$pH_calculated)

  shapiro.test(season.data$pH_calculated) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  season.data$pH_calculated
## W = 0.97823, p-value = 2.099e-12
  # pH_season<-lmer(pH_calculated~ Zone + Sub_region + Season +
  #                          Zone:Sub_region + Zone:Season + Sub_region:Season+   
  #                          (1|SiteID), data=season.data)
  pH_season<-lmer(pH_calculated~ Zone * Sub_region * Season *
                           (1|SiteID), data=season.data)
  
        #summary(pH_season)    
        av.pH_season<-anova(pH_season)
        av.pH_season
        ranova(pH_season)
        #step(pH_season)
        
        plot(pH_season)

        par(mfrow=c(1,2))
        qqnorm(resid(pH_season))
        acf(resid(pH_season), main="acf(resid(dTA Season))")

        par(mfrow=c(1,1))
  #summ(pH_season, scale = TRUE)
  #plot_summs(pH_season)  
  
  pH_ses.emmc<-emmeans(pH_season, ~Zone*Sub_region*Season)
    pH_ses.emmc<-multcomp::cld(pH_ses.emmc)
    pH_ses.emmc<-as.data.frame(pH_ses.emmc[complete.cases(pH_ses.emmc),])
    pH_ses.emmc<-pH_ses.emmc[order(pH_ses.emmc$Zone, pH_ses.emmc$Season), ]
  pH_ses.emmc
  pH_ses.emmc<-emmeans(pH_season, ~Zone, by = "Sub_region")
    pH_ses.emmc<-multcomp::cld(pH_ses.emmc)
    pH_ses.emmc<-as.data.frame(pH_ses.emmc[complete.cases(pH_ses.emmc),])
    #pH_ses.emmc<-pH_ses.emmc[order(pH_ses.emmc$Zone, pH_ses.emmc$Season), ]
  pH_ses.emmc
  pH_ses.emmc<-emmeans(pH_season, ~Zone)
    pH_ses.emmc<-multcomp::cld(pH_ses.emmc)
    pH_ses.emmc<-as.data.frame(pH_ses.emmc[complete.cases(pH_ses.emmc),])
    #pH_ses.emmc<-pH_ses.emmc[order(pH_ses.emmc$Zone, pH_ses.emmc$Season), ]
  pH_ses.emmc

LMER - all dpH - MODEL 15

# Inshore Omega
  hist(season.data$dpH_MY)

  shapiro.test(season.data$dpH_MY) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  season.data$dpH_MY
## W = 0.93766, p-value < 2.2e-16
  # dpH_season<-lmer(Aragonite_Sat_W~  Zone + Sub_region + Season +
  #                          Zone:Sub_region + Zone:Season + Sub_region:Season+   
  #                          (1|SiteID), data=season.data)
  dpH_season<-lmer(dpH_MY~  Zone * Sub_region * Season +
                           (1|SiteID), data=season.data)
  
  #summary(dpH_season)    
  av.dpH_season<-anova(dpH_season)
  av.dpH_season
  ranova(dpH_season)
  #step(dpH_season)
  
  plot(dpH_season)

  par(mfrow=c(1,2))
  qqnorm(resid(dpH_season))
  acf(resid(dpH_season), main="acf(resid(dTA Season))")

  par(mfrow=c(1,1))
  #plot_summs(dpH_season)  
    
dpH_ses.emmc<-emmeans(dpH_season, ~Zone*Season, by="Sub_region")
    dpH_ses.emmc<-multcomp::cld(dpH_ses.emmc)
    dpH_ses.emmc
dpH_ses.emmc<-emmeans(dpH_season, ~Sub_region)
    dpH_ses.emmc<-multcomp::cld(dpH_ses.emmc)
    dpH_ses.emmc
dpH_ses.emmc2<-emmeans(dpH_season, ~Season*Sub_region, by="Zone")
    dpH_ses.emmc2<-multcomp::cld(dpH_ses.emmc2)
    #dTA_ses.emmc<-as.data.frame(dTA_ses.emmc[complete.cases(dTA_ses.emmc),])
    dpH_ses.emmc2<-dpH_ses.emmc2[order(dpH_ses.emmc2$Zone, 
                                     dpH_ses.emmc2$Season, 
                                     dpH_ses.emmc2$Sub_region), ]
  #dpH_ses.emmc2

  dpH_ses.emmc2[,-c(3)] %>% kable("html", digits=2, row.names = F,
                                   caption = "Seasonal d pH") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Offshore", 1, 16) %>% # groups rows with zone label
      pack_rows(., "Mid-Channel", 17, 32) %>%
      pack_rows(., "Inshore", 33, 48)
Seasonal d pH
Season Sub_region emmean SE df lower.CL upper.CL .group
Offshore
Winter BB 0.01 0.01 145.67 -0.01 0.03 1
Winter UK 0.01 0.01 168.69 -0.01 0.03 1
Winter MK 0.00 0.01 150.14 -0.01 0.02 1
Winter LK 0.00 0.01 144.97 -0.02 0.01 1
Spring BB 0.00 0.01 122.12 -0.02 0.02 1
Spring UK 0.00 0.01 140.91 -0.02 0.02 1
Spring MK 0.01 0.01 108.39 -0.01 0.03 1
Spring LK -0.01 0.01 105.48 -0.02 0.01 1
Summer BB -0.02 0.01 159.91 -0.04 0.00 1
Summer UK -0.01 0.01 181.14 -0.03 0.01 1
Summer MK -0.01 0.01 159.91 -0.03 0.01 1
Summer LK -0.02 0.01 185.37 -0.04 0.00 1
Fall BB 0.00 0.01 113.58 -0.02 0.02 1
Fall UK 0.00 0.01 141.43 -0.02 0.02 1
Fall MK 0.00 0.01 108.39 -0.01 0.02 1
Fall LK 0.00 0.01 109.55 -0.02 0.01 1
Mid-Channel
Winter BB 0.01 0.01 159.91 -0.01 0.03 123456
Winter UK 0.03 0.01 176.00 0.00 0.05 3456
Winter MK 0.01 0.01 150.14 0.00 0.03 3456
Winter LK -0.01 0.01 113.74 -0.03 0.00 12345
Spring BB 0.02 0.01 158.94 0.00 0.05 456
Spring UK 0.03 0.01 145.64 0.01 0.06 56
Spring MK 0.04 0.01 103.33 0.02 0.05 6
Spring LK 0.01 0.01 94.36 -0.01 0.02 23456
Summer BB -0.03 0.01 159.91 -0.05 -0.01 123
Summer UK -0.01 0.01 193.98 -0.04 0.01 12345
Summer MK -0.03 0.01 159.91 -0.05 -0.01 12
Summer LK -0.04 0.01 182.17 -0.06 -0.02 1
Fall BB -0.02 0.01 123.05 -0.04 0.00 12345
Fall UK -0.01 0.01 145.64 -0.04 0.01 12345
Fall MK -0.01 0.01 113.97 -0.03 0.01 12345
Fall LK -0.02 0.01 98.72 -0.03 0.00 1234
Inshore
Winter BB 0.01 0.01 145.67 -0.01 0.04 456
Winter UK 0.03 0.01 194.52 0.02 0.05 567
Winter MK 0.02 0.01 182.15 0.00 0.04 56
Winter LK -0.01 0.01 125.83 -0.03 0.01 345
Spring BB 0.05 0.01 122.14 0.03 0.07 678
Spring UK 0.10 0.01 159.91 0.08 0.11 8
Spring MK 0.07 0.01 94.35 0.05 0.08 78
Spring LK 0.02 0.01 90.36 0.00 0.03 56
Summer BB -0.06 0.01 159.91 -0.08 -0.04 12
Summer UK -0.03 0.01 159.91 -0.05 -0.01 234
Summer MK -0.05 0.01 170.33 -0.07 -0.03 23
Summer LK -0.10 0.01 210.11 -0.12 -0.08 1
Fall BB -0.05 0.01 105.80 -0.07 -0.03 23
Fall UK -0.06 0.01 159.91 -0.08 -0.05 12
Fall MK -0.03 0.01 113.72 -0.05 -0.01 234
Fall LK -0.06 0.01 98.72 -0.07 -0.04 2
  dpH_year.emmc<-emmeans(dpH_season, ~Sub_region*Zone)
    dpH_year.emmc<-multcomp::cld(dpH_year.emmc)
    #dTA_ses.emmc<-as.data.frame(dTA_ses.emmc[complete.cases(dTA_ses.emmc),])
    dpH_year.emmc<-dpH_year.emmc[order(dpH_year.emmc$Zone, 
                                      dpH_year.emmc$Sub_region), ]
  #dDIC_year.emmc
  
  dpH_year.emmc[,-c(2)] %>% kable("html", digits=2, row.names = F,
                                  caption = "Year d pH") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Offshore", 1, 4) %>% # groups rows with zone label
      pack_rows(., "Mid-Channel", 5, 8) %>%
      pack_rows(., "Inshore", 9, 12)
Year d pH
Sub_region emmean SE df lower.CL upper.CL .group
Offshore
BB 0.00 0.01 20.91 -0.02 0.01 2
UK 0.00 0.01 23.46 -0.01 0.01 2
MK 0.00 0.01 20.45 -0.01 0.01 2
LK -0.01 0.00 20.94 -0.02 0.00 2
Mid-Channel
BB 0.00 0.01 22.56 -0.02 0.01 2
UK 0.01 0.01 24.20 -0.01 0.02 2
MK 0.00 0.01 20.46 -0.01 0.01 2
LK -0.02 0.01 19.33 -0.03 -0.01 12
Inshore
BB -0.01 0.01 20.68 -0.03 0.00 12
UK 0.01 0.01 24.55 0.00 0.02 2
MK 0.00 0.01 21.28 -0.01 0.01 2
LK -0.04 0.01 20.22 -0.05 -0.03 1

Figure 4C: Model

dpH_ses_2.emmc<-as.data.frame(dpH_ses.emmc2)
dpH_ye_3.emmc<-as.data.frame(dpH_year.emmc)
dpH_ye_3.emmc$Season<-"Mean"

dpH_all_4<-rbind(dpH_ses_2.emmc, dpH_ye_3.emmc)
dpH_all_4$Zone<-factor(dDIC_all_4$Zone, 
                          levels=c("Inshore" , "Mid channel", "Offshore"))


DeltaYearpH<- ggplot(dpH_all_4, aes(x=Season, y=emmean, fill=Sub_region)) +
        MyTheme +  
        #facet_grid(Zone~., scales = "free_y")+
        facet_grid(~Zone, scales="free" )+
        geom_hline(yintercept = 0, color="gray")+
        theme(axis.title.x = element_blank(),
              legend.position = "bottom",
              axis.text.x = element_text(angle = 0))+

    scale_y_continuous(#limits = c(-350,340),
                     expand = c(0.01, 0.01),
                     breaks = seq(-6, 6, 0.05),
                     name=(expression (paste(Delta ,
                          ~pH[]))))+
    geom_bar(position = "dodge", color="black", 
           stat = "summary",
           fun = "mean")+
  geom_errorbar(aes(ymin=emmean-SE, ymax=emmean+SE), width=0.2,
                 position=position_dodge(.9)) 

DeltaYearpH

LMER - pH Inshore

# Inshore pH
  hist(inshore.season.data$pH_calculated)

  shapiro.test(inshore.season.data$pH_calculated) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  inshore.season.data$pH_calculated
## W = 0.99421, p-value = 0.1375
  pH_season_in<-lmer(pH_calculated~  Sub_region * Season +
                           (1|SiteID), data=inshore.season.data)
  
    #summary(pH_season_in)    
    av.pH_season_in<-anova(pH_season_in)
    av.pH_season_in
    ranova(pH_season_in)
    #step(pH_season_in)
    
    plot(pH_season_in)

    par(mfrow=c(1,2))
    qqnorm(resid(pH_season_in))
    acf(resid(pH_season_in), main="acf(resid(dTA Season))")

    par(mfrow=c(1,1))
    #summ(pH_season_in, scale = TRUE)
    #plot_summs(pH_season_in)
  
  pH_ses_in.emmc<-emmeans(pH_season_in, ~ Sub_region*Season)
    pH_ses_in.emmc<-multcomp::cld(pH_ses_in.emmc)
    #pH_ses_in.emmc<-as.data.frame(pH_ses_in.emmc[complete.cases(pH_ses_in.emmc),])
    pH_ses_in.emmc<-pH_ses_in.emmc[order(pH_ses_in.emmc$Season,
                                           pH_ses_in.emmc$Sub_region), ]
  pH_ses_in.emmc

Summary all data

# ANOVAs
    # Convert ANOVA results into dataframes allows for easier name manipulation
    av.dTA_season <- data.frame(av.dTA_season)
    av.dDIC_season <- data.frame(av.dDIC_season) 
    av.dPCO2_season <- data.frame(av.dPCO2_season)
    av.dOme_season <- data.frame(av.dOme_season) 
    av.dpH_season <- data.frame(av.dpH_season) 
    
    # Putting all into one dataframe/table
    anova_results_all <- data.frame(cbind
                    (c("Zone", "Sub_region", "Season", "Zone:Sub_region", "Zone:Season",
                       "Sub_region:Season", "Zone:Sub_region:Season",
                       
                       "Zone", "Sub_region", "Season", "Zone:Sub_region", "Zone:Season",
                       "Sub_region:Season", "Zone:Sub_region:Season",
                       
                       "Zone", "Sub_region", "Season", "Zone:Sub_region", "Zone:Season",
                       "Sub_region:Season", "Zone:Sub_region:Season",
                       
                       "Zone", "Sub_region", "Season", "Zone:Sub_region", "Zone:Season",
                       "Sub_region:Season", "Zone:Sub_region:Season",
                       
                       "Zone", "Sub_region", "Season", "Zone:Sub_region", "Zone:Season",
                       "Sub_region:Season", "Zone:Sub_region:Season"), 
                                      rbind(av.dTA_season, av.dDIC_season, av.dPCO2_season,
                                            av.dOme_season, av.dpH_season ))) 
    colnames(anova_results_all) <- c("", "Sum Sq", "Mean Sq", "N Df" , "D Df",
                                     "F value", "Pr(>F)")
    row.names(anova_results_all) <- NULL
    
    # create HTML table using kableExtra
    anova_results_all %>% kable("html", digits=2) %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "d TA", 1, 7) %>% # groups rows with label
      pack_rows(., "d DIC", 8, 14)  %>% # groups rows with label
      pack_rows(., "d pCO2", 15, 21) %>% # groups rows with label
      pack_rows(., "d Omega", 22, 28)  %>% # groups rows with label
      pack_rows(., "d pH", 29, 35)  
Sum Sq Mean Sq N Df D Df F value Pr(>F)
d TA
Zone 147511.18 73755.59 2 24.33 33.83 0.00
Sub_region 255038.82 85012.94 3 24.08 39.00 0.00
Season 857202.03 285734.01 3 1118.93 131.07 0.00
Zone:Sub_region 194809.81 32468.30 6 24.08 14.89 0.00
Zone:Season 564721.55 94120.26 6 1118.94 43.17 0.00
Sub_region:Season 161239.24 17915.47 9 1118.88 8.22 0.00
Zone:Sub_region:Season 85053.62 4725.20 18 1118.89 2.17 0.00
d DIC
Zone 50385.20 25192.60 2 23.49 10.81 0.00
Sub_region 85646.72 28548.91 3 23.38 12.25 0.00
Season 1361232.88 453744.29 3 1113.08 194.76 0.00
Zone:Sub_region 65760.45 10960.07 6 23.37 4.70 0.00
Zone:Season 1013441.05 168906.84 6 1113.08 72.50 0.00
Sub_region:Season 174759.19 19417.69 9 1113.05 8.33 0.00
Zone:Sub_region:Season 102157.02 5675.39 18 1113.06 2.44 0.00
d pCO2
Zone 16149.26 8074.63 2 21.97 3.34 0.05
Sub_region 62914.07 20971.36 3 21.87 8.67 0.00
Season 908279.53 302759.84 3 1109.76 125.20 0.00
Zone:Sub_region 17081.00 2846.83 6 21.87 1.18 0.35
Zone:Season 618840.71 103140.12 6 1109.76 42.65 0.00
Sub_region:Season 70185.63 7798.40 9 1109.73 3.22 0.00
Zone:Sub_region:Season 64511.25 3583.96 18 1109.73 1.48 0.09
d Omega
Zone 2.27 1.14 2 21.43 14.50 0.00
Sub_region 6.84 2.28 3 21.29 29.06 0.00
Season 32.27 10.76 3 1109.53 137.17 0.00
Zone:Sub_region 2.86 0.48 6 21.29 6.08 0.00
Zone:Season 20.30 3.38 6 1109.54 43.15 0.00
Sub_region:Season 2.60 0.29 9 1109.49 3.68 0.00
Zone:Sub_region:Season 1.93 0.11 18 1109.50 1.37 0.14
d pH
Zone 0.01 0.00 2 22.29 1.91 0.17
Sub_region 0.07 0.02 3 22.19 14.15 0.00
Season 0.68 0.23 3 1110.09 132.93 0.00
Zone:Sub_region 0.03 0.00 6 22.19 2.73 0.04
Zone:Season 0.40 0.07 6 1110.10 39.14 0.00
Sub_region:Season 0.04 0.00 9 1110.06 2.74 0.00
Zone:Sub_region:Season 0.04 0.00 18 1110.07 1.22 0.24
#export_summs(dTA_season, dDIC_season, dpCO2_season,  scale = TRUE)
      
      Seasonal_models<-list("d TA" = dTA_season, 
                         "d DIC" = dDIC_season, 
                         "d pCO2" = dpCO2_season, 
                         "Omega" = Omega_season,
                         "pH" = pH_season)
      
      modelsummary(Seasonal_models, stars = TRUE, 
                   #statistic = c('std.error', 'p.value', 'conf.int'),
                   title = 'Seasonal and spatial models'#,
                   #coef_map=factor_order
                   )
Seasonal and spatial models
d TA d DIC d pCO2 Omega pH
(Intercept) 1.046 −1.154 −7.599 3.699*** 8.074***
(11.744) (12.788) (13.287) (0.071) (0.012)
ZoneMid channel 6.972 11.804 1.346 −0.061 −0.002
(16.848) (18.319) (19.024) (0.101) (0.017)
ZoneInshore 39.553* 48.017** 4.049 −0.083 0.006
(16.609) (18.085) (18.791) (0.100) (0.016)
Sub_regionUK 2.844 1.067 −1.212 −0.009 −0.003
(15.469) (16.815) (17.460) (0.093) (0.015)
Sub_regionMK 3.549 9.085 5.807 −0.057 −0.004
(15.218) (16.565) (17.209) (0.091) (0.015)
Sub_regionLK 0.897 8.471 9.595 −0.110 −0.010
(14.386) (15.544) (16.277) (0.086) (0.014)
SeasonSpring −4.947 0.623 9.927 0.056 −0.036*
(15.590) (16.118) (16.422) (0.089) (0.015)
SeasonSummer −6.558 7.034 33.200+ 0.178+ −0.075***
(16.264) (16.814) (17.130) (0.095) (0.016)
SeasonFall −1.881 4.705 12.232 0.059 −0.035*
(15.403) (15.923) (16.223) (0.090) (0.015)
ZoneMid channelSub_regionUK −0.203 −9.981 −15.883 0.121 0.020
(23.243) (25.231) (26.187) (0.139) (0.023)
ZoneInshoreSub_regionUK 5.298 −4.833 −18.158 0.105 0.020
(22.080) (23.979) (24.890) (0.133) (0.022)
ZoneMid channelSub_regionMK 13.672 4.725 −6.314 0.118 0.014
(21.706) (23.607) (24.518) (0.130) (0.022)
ZoneInshoreSub_regionMK 12.850 −0.447 −11.098 0.157 0.014
(21.796) (23.696) (24.607) (0.131) (0.022)
ZoneMid channelSub_regionLK 4.635 12.672 18.773 −0.036 −0.007
(20.785) (22.561) (23.534) (0.125) (0.021)
ZoneInshoreSub_regionLK −34.138+ −27.489 12.904 −0.069 −0.011
(20.719) (22.498) (23.471) (0.125) (0.021)
ZoneMid channelSeasonSpring −11.688 −33.176 −31.337 0.215+ 0.031
(22.708) (23.479) (23.921) (0.129) (0.022)
ZoneInshoreSeasonSpring −98.226*** −138.451*** −67.932** 0.398** 0.048*
(22.048) (22.795) (23.224) (0.125) (0.021)
ZoneMid channelSeasonSummer −15.240 −13.658 7.610 −0.021 −0.007
(23.174) (23.957) (24.407) (0.135) (0.023)
ZoneInshoreSeasonSummer −80.288*** −64.312** 48.003* −0.196 −0.047*
(23.001) (23.778) (24.225) (0.134) (0.022)
ZoneMid channelSeasonFall −2.072 6.809 17.624 −0.088 −0.013
(22.097) (22.843) (23.273) (0.129) (0.021)
ZoneInshoreSeasonFall −12.472 21.724 69.956** −0.357** −0.053*
(21.663) (22.395) (22.816) (0.126) (0.021)
Sub_regionUKSeasonSpring −0.927 −2.048 −1.717 0.044 0.004
(20.544) (21.247) (21.649) (0.118) (0.020)
Sub_regionMKSeasonSpring −7.109 −22.158 −21.626 0.161 0.019
(20.015) (20.693) (21.083) (0.114) (0.019)
Sub_regionLKSeasonSpring −8.497 −14.026 −4.731 0.079 0.003
(18.952) (19.499) (19.965) (0.109) (0.018)
Sub_regionUKSeasonSummer −2.100 −9.926 −12.532 0.114 0.013
(21.410) (22.134) (22.551) (0.125) (0.021)
Sub_regionMKSeasonSummer −22.755 −35.401 −25.781 0.119 0.015
(21.037) (21.748) (22.157) (0.122) (0.020)
Sub_regionLKSeasonSummer −5.819 −14.001 −12.088 0.102 0.011
(19.920) (20.685) (21.168) (0.117) (0.020)
Sub_regionUKSeasonFall −2.590 −1.883 −2.761 0.012 0.002
(20.395) (21.085) (21.482) (0.119) (0.020)
Sub_regionMKSeasonFall −4.033 −12.248 −12.350 0.085 0.012
(19.870) (20.542) (20.928) (0.116) (0.019)
Sub_regionLKSeasonFall −3.416 −10.847 −11.405 0.114 0.011
(18.830) (19.370) (19.833) (0.110) (0.018)
ZoneMid channelSub_regionUKSeasonSpring 3.876 3.803 9.623 0.013 −0.017
(31.118) (32.179) (32.787) (0.178) (0.030)
ZoneInshoreSub_regionUKSeasonSpring −1.712 −28.339 −22.426 0.260 0.030
(29.322) (30.322) (30.894) (0.167) (0.028)
ZoneMid channelSub_regionMKSeasonSpring −38.793 −35.462 1.763 −0.066 −0.019
(28.785) (29.760) (30.321) (0.164) (0.027)
ZoneInshoreSub_regionMKSeasonSpring −27.637 −25.920 4.822 −0.060 −0.008
(28.405) (29.367) (29.920) (0.162) (0.027)
ZoneMid channelSub_regionLKSeasonSpring −37.531 −38.693 −9.099 −0.022 −0.006
(27.725) (28.600) (29.207) (0.159) (0.026)
ZoneInshoreSub_regionLKSeasonSpring −20.178 −7.628 6.718 −0.174 −0.017
(27.248) (28.106) (28.704) (0.156) (0.026)
ZoneMid channelSub_regionUKSeasonSummer 7.655 11.814 10.293 −0.036 −0.013
(32.125) (33.211) (33.835) (0.187) (0.031)
ZoneInshoreSub_regionUKSeasonSummer 4.972 −1.293 −9.457 0.079 −0.001
(30.292) (31.317) (31.907) (0.176) (0.029)
ZoneMid channelSub_regionMKSeasonSummer −53.984+ −42.356 11.077 −0.163 −0.025
(29.885) (30.895) (31.476) (0.174) (0.029)
ZoneInshoreSub_regionMKSeasonSummer −96.163** −85.210** −17.181 −0.216 −0.012
(30.016) (31.031) (31.615) (0.175) (0.029)
ZoneMid channelSub_regionLKSeasonSummer −62.480* −68.959* −15.707 −0.053 −0.005
(28.859) (30.045) (30.675) (0.169) (0.028)
ZoneInshoreSub_regionLKSeasonSummer −98.607*** −68.791* 12.371 −0.299+ −0.027
(28.954) (30.172) (30.804) (0.170) (0.028)
ZoneMid channelSub_regionUKSeasonFall −3.487 4.409 14.884 −0.107 −0.017
(30.668) (31.705) (32.301) (0.178) (0.030)
ZoneInshoreSub_regionUKSeasonFall 12.622 28.658 44.740 −0.141 −0.029
(29.029) (30.012) (30.577) (0.169) (0.028)
ZoneMid channelSub_regionMKSeasonFall −10.085 −1.136 5.312 −0.117 −0.013
(28.385) (29.345) (29.897) (0.165) (0.028)
ZoneInshoreSub_regionMKSeasonFall −21.816 −19.427 −16.350 −0.045 0.003
(28.262) (29.218) (29.768) (0.164) (0.027)
ZoneMid channelSub_regionLKSeasonFall −17.841 −27.429 −21.551 0.047 0.010
(27.283) (28.139) (28.736) (0.159) (0.027)
ZoneInshoreSub_regionLKSeasonFall −52.807+ −50.897+ −24.516 −0.087 0.005
(27.030) (27.877) (28.471) (0.157) (0.026)
SD (Intercept SiteID) 4.397 7.272 8.276 0.036 0.005
SD (Observations) 46.691 48.267 49.175 0.272 0.045
Num.Obs. 1184 1179 1177 1191 1191
R2 Marg. 0.500 0.535 0.383 0.451 0.457
R2 Cond. 0.504 0.545 0.400 0.460 0.464
AIC 12214.1 12243.0 12266.0 527.1 −3564.8
BIC 12467.9 12496.6 12519.6 781.2 −3310.6
ICC 0.0 0.0 0.0 0.0 0.0
RMSE 45.63 47.08 47.94 0.27 0.04
+ p
      #modelsummary(Omega_models, estimate = "p.value")

Summary all inshore

# ANOVAs
    # Convert ANOVA results into dataframes allows for easier name manipulation
    av.dTA_season_in <- data.frame(av.dTA_season_in)
    av.dDIC_season_in <- data.frame(av.dDIC_season_in) 
    av.dPCO2_season_in <- data.frame(av.dPCO2_season_in)
    av.Ome_season_in <- data.frame(av.Ome_season_in) 
    av.pH_season_in <- data.frame(av.pH_season_in) 
    
    # Putting all into one dataframe/table
    anova_results_In <- data.frame(cbind
                    (c("Sub_region", "Season", "Sub_region:Season", 
                       
                       "Sub_region", "Season", "Sub_region:Season",
                       
                       "Sub_region", "Season", "Sub_region:Season",
                       
                       "Sub_region", "Season", "Sub_region:Season",
                       
                       "Sub_region", "Season", "Sub_region:Season"), 
                                      rbind(av.dTA_season_in, av.dDIC_season_in,
                                            av.dPCO2_season_in,
                                            av.Ome_season_in, av.pH_season_in))) 
    colnames(anova_results_In) <- c("", "Sum Sq", "Mean Sq", "N Df" , "D Df",
                                     "F value", "Pr(>F)")
    row.names(anova_results_In) <- NULL
    
    # create HTML table using kableExtra
    anova_results_In %>% kable("html", digits=2) %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "d TA inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "d DIC inshore", 4, 6)  %>% # groups rows with label
      pack_rows(., "d pCO2 inshore", 7, 9) %>% # groups rows with label
      pack_rows(., "Omega inshore", 10, 12)  %>% # groups rows with label
      pack_rows(., "pH inshore", 13, 15)  
Sum Sq Mean Sq N Df D Df F value Pr(>F)
d TA inshore
Sub_region 450697.69 150232.56 3 8.42 32.03 0.00
Season 1250626.86 416875.62 3 371.65 88.88 0.00
Sub_region:Season 166830.83 18536.76 9 371.64 3.95 0.00
d DIC inshore
Sub_region 121639.36 40546.45 3 7.81 7.96 0.01
Season 2120498.90 706832.97 3 369.01 138.78 0.00
Sub_region:Season 181134.87 20126.10 9 369.01 3.95 0.00
d pCO2 inshore
Sub_region 48532.82 16177.61 3 7.24 3.15 0.09
Season 1336460.93 445486.98 3 368.48 86.75 0.00
Sub_region:Season 108532.96 12059.22 9 368.48 2.35 0.01
Omega inshore
Sub_region 6.03 2.01 3 7.07 14.60 0.00
Season 40.79 13.60 3 374.36 98.84 0.00
Sub_region:Season 3.52 0.39 9 374.36 2.85 0.00
pH inshore
Sub_region 0.07 0.02 3 7.44 6.18 0.02
Season 1.32 0.44 3 374.69 109.72 0.00
Sub_region:Season 0.07 0.01 9 374.70 1.86 0.06
#export_summs(dTA_season, dDIC_season, dpCO2_season,  scale = TRUE)
    Seasonal_models_in<-list("d TA" = dTA_season_in, 
                       "d DIC" = dDIC_season_in, 
                       "d pCO2" = dpCO2_season_in, 
                       "Omega" = Omega_season_in,
                       "pH" = pH_season_in)
    
    modelsummary(Seasonal_models_in, stars = TRUE, 
                 #statistic = c('std.error', 'p.value', 'conf.int'),
                 title = 'Seasonal and spatial models for inshore reefs'#,
                 #coef_map=factor_order
                 )
Seasonal and spatial models for inshore reefs
d TA d DIC d pCO2 Omega pH
(Intercept) 40.632* 46.843* −3.618 3.617*** 8.080***
(16.867) (19.066) (19.926) (0.099) (0.017)
Sub_regionUK 8.140 −3.738 −19.226 0.094 0.017
(22.663) (25.473) (26.556) (0.132) (0.022)
Sub_regionMK 16.388 8.657 −5.210 0.099 0.009
(22.437) (25.251) (26.340) (0.131) (0.022)
Sub_regionLK −33.045 −19.049 22.510 −0.179 −0.021
(21.397) (24.255) (25.380) (0.126) (0.021)
SeasonSpring −103.117*** −137.861*** −58.117* 0.455*** 0.012
(22.865) (23.833) (23.932) (0.121) (0.021)
SeasonSummer −86.879*** −57.259* 81.270** −0.018 −0.122***
(23.855) (24.860) (24.964) (0.129) (0.022)
SeasonFall −14.359 26.433 82.201*** −0.298* −0.088***
(22.344) (23.284) (23.380) (0.121) (0.021)
Sub_regionUKSeasonSpring −2.726 −30.364 −24.107 0.303+ 0.034
(30.686) (31.985) (32.120) (0.162) (0.028)
Sub_regionMKSeasonSpring −34.810 −48.046 −16.696 0.100 0.011
(29.563) (30.811) (30.939) (0.158) (0.027)
Sub_regionLKSeasonSpring −28.905 −21.590 2.108 −0.095 −0.013
(28.713) (29.930) (30.056) (0.153) (0.026)
Sub_regionUKSeasonSummer 2.874 −11.247 −22.133 0.194 0.012
(31.431) (32.758) (32.895) (0.170) (0.029)
Sub_regionMKSeasonSummer −118.938*** −120.630*** −43.065 −0.096 0.004
(31.403) (32.727) (32.863) (0.170) (0.029)
Sub_regionLKSeasonSummer −104.496*** −82.765* 0.301 −0.197 −0.016
(30.818) (32.477) (32.613) (0.169) (0.029)
Sub_regionUKSeasonFall 10.007 26.763 41.889 −0.128 −0.027
(30.300) (31.579) (31.710) (0.164) (0.028)
Sub_regionMKSeasonFall −25.859 −31.677 −28.721 0.040 0.015
(29.476) (30.722) (30.851) (0.160) (0.027)
Sub_regionLKSeasonFall −56.447* −61.698* −35.879 0.027 0.015
(28.442) (29.644) (29.768) (0.154) (0.026)
SD (Intercept SiteID) 4.142 11.295 13.772 0.058 0.010
SD (Observations) 68.485 71.367 71.662 0.371 0.063
Num.Obs. 393 391 391 397 397
R2 Marg. 0.517 0.562 0.423 0.503 0.481
R2 Cond. 0.519 0.573 0.444 0.515 0.492
AIC 4344.4 4356.2 4360.7 416.9 −931.7
BIC 4415.9 4427.7 4432.2 488.6 −860.0
ICC 0.0 0.0 0.0 0.0 0.0
RMSE 67.00 69.58 69.81 0.36 0.06
+ p
    #modelsummary(Omega_models, estimate = "p.value")

Figure 4: Models

Figure_4<-ggarrange(DeltaYearTA+ theme(axis.title.x=element_blank(),
                                 axis.text.x=element_blank(),
                                 legend.position = "none"),
                  DeltaYearDIC+ theme(legend.position = "none",
                                 axis.title.x=element_blank(),
                                 axis.text.x=element_blank(),
                                 strip.text.x = element_blank()),
                  DeltaYearpH + theme(legend.position = "none",
                                 axis.title.x=element_blank(),
                                 axis.text.x=element_blank(),
                                 strip.text.x = element_blank()),
                  DeltaYearAra+ theme(legend.position = "bottom",
                                 strip.text.x = element_blank(),
                                 panel.spacing = unit(0.8, "lines")),
          labels = c("A", "B", "C", "D"),
          ncol = 1, nrow = 4, heights = c(1, 0.9, 0.9, 1.2))
Figure_4

#ggsave(file="FLK_results/Figures/Fig_4/Figure_4.svg", plot=Figure_4, dpi = 300, width=8, height=7)

6 LMER long trend MODELS

  • The F statistic in a regression model is used to test whether there is a linear model of the data - overall , or equivalently that your model is no better than a model with just the intercept.

  • The t statistic for a coefficient in a linear model tests the H0 that the true coefficient is 0.

*The t-statistic is telling you about each coefficient individually. You can have a model with a low overall linear fit, but one individual coefficient may be relatively contributing a lot to explanation the variation in the DV that is explained on the assumption that there is a linear model.

Data and plots prep

Trends.data<-FLK.data_filtered[FLK.data_filtered$Year>2014, ]
#summary(Trends.data)

Reef.Trends.data<-WS.reef[WS.reef$Year>2014, ]
Reef.Trends.data<-Reef.Trends.data[Reef.Trends.data$Extreme=="Normal", ]
#summary(Reef.Trends.data$Extreme)

Trends.ocean<-Trends.data[Trends.data$Zone=="Oceanic", ]

Trends.offshore<-Reef.Trends.data[Reef.Trends.data$Zone=="Offshore", ]
Trends.midchanel<-Reef.Trends.data[Reef.Trends.data$Zone=="Mid channel", ]
Trends.inshore<-Reef.Trends.data[Reef.Trends.data$Zone=="Inshore", ]

Long_plot<- ggplot(Trends.data) +
        MyTheme +  
        #scale_shape_manual(values=c(24, 25, 21))+
        #guides(fill=guide_legend(override.aes=list(shape=21)))+
        theme(axis.title.x = element_blank())+
        scale_x_date(date_breaks = "2 years",
                     date_labels = "%Y",
                     expand = c(0.02, 0.02))

Long_plot2<- ggplot() +
        MyTheme +  
        #scale_shape_manual(values=c(24, 25, 21))+
        #guides(fill=guide_legend(override.aes=list(shape=21)))+
        theme(axis.title.x = element_blank(),
                axis.text.x = element_text(angle = 0, vjust = 0.5))+
        scale_x_date(date_breaks = "2 years",
                     date_labels = "%Y",
                     expand = c(0.02, 0.02))
xs <- as.Date(as.character("2018-11-20"))

factor_order <- c('Year'    = 'Year',
                  '(Intercept)' = 'Intercept',
                  'Sub_regionUK'    = 'Upper Keys',
                  'Sub_regionMK'    = 'Middle Keys',
                  'Sub_regionLK'    = 'Lower Keys')

Temperature-All

## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.data$Aragonite_Sat_W
## W = 0.97129, p-value = 1.141e-14

## Model with all data
Temo_all_o<-lmer(Temperature_C~Year * Zone * Sub_region + (1|Month)+           
                                    (1|SiteID), data=Trends.data)
  step(Temo_all_o)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC  LRT Df Pr(>Chisq)    
## <none>                    33 -1972.7 4011.4                       
## (1 | SiteID)          1   32 -1972.7 4009.4    0  1     0.9999    
## (1 | Month)           0   31 -2983.2 6028.4 2021  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                      Eliminated  Sum Sq Mean Sq NumDF  DenDF F value    Pr(>F)
## Year:Zone:Sub_region          1  5.3283  0.6660     8 1168.0  0.4835 0.8685435
## Zone:Sub_region               2  6.4624  0.8078     8 1176.0  0.5885 0.7880553
## Year:Sub_region               3  7.7544  2.5848     3 1184.0  1.8882 0.1297461
## Year:Zone                     4  9.4256  3.1419     3 1187.0  2.2900 0.0767345
## Year                          0  9.4429  9.4429     1 1193.3  6.8602 0.0089254
## Zone                          0 24.4041  8.1347     3 1190.0  5.9098 0.0005303
## Sub_region                    0 12.4609  4.1536     3 1190.0  3.0176 0.0289965
##                         
## Year:Zone:Sub_region    
## Zone:Sub_region         
## Year:Sub_region         
## Year:Zone            .  
## Year                 ** 
## Zone                 ***
## Sub_region           *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## Temperature_C ~ Year + Zone + Sub_region + (1 | Month)
Temp_all_1<-lmer(Temperature_C ~ Year + Zone + (1 | Month) +
                      Year:Zone, data=Trends.data)

anova(Temp_all_1, Temo_all_o)
    summary(Temp_all_1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Temperature_C ~ Year + Zone + (1 | Month) + Year:Zone
##    Data: Trends.data
## 
## REML criterion at convergence: 3915
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -7.4600 -0.5255 -0.0322  0.4641  3.4157 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 8.590    2.931   
##  Residual             1.379    1.174   
## Number of obs: 1209, groups:  Month, 12
## 
## Fixed effects:
##                        Estimate Std. Error         df t value Pr(>|t|)  
## (Intercept)            48.94886   66.81149 1191.80186   0.733   0.4639  
## Year                   -0.01089    0.03311 1191.44747  -0.329   0.7423  
## ZoneMid channel      -150.34547   87.86814 1190.00171  -1.711   0.0873 .
## ZoneOffshore         -196.85780   83.62755 1189.93954  -2.354   0.0187 *
## ZoneOceanic          -219.85553  110.22230 1189.96051  -1.995   0.0463 *
## Year:ZoneMid channel    0.07463    0.04355 1190.00171   1.714   0.0868 .
## Year:ZoneOffshore       0.09771    0.04144 1189.93954   2.357   0.0186 *
## Year:ZoneOceanic        0.10917    0.05462 1189.96052   1.998   0.0459 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   ZnMdch ZnOffs ZnOcnc Yr:ZMc Yr:ZnOf
## Year        -1.000                                           
## ZoneMdchnnl -0.634  0.634                                    
## ZoneOffshor -0.668  0.668  0.506                             
## ZoneOceanic -0.510  0.510  0.384  0.404                      
## Yr:ZnMdchnn  0.634 -0.634 -1.000 -0.506 -0.384               
## Yr:ZnOffshr  0.668 -0.668 -0.506 -1.000 -0.404  0.506        
## Year:ZnOcnc  0.510 -0.510 -0.384 -0.404 -1.000  0.384  0.404
    anova(Temp_all_1)
    ranova(Temp_all_1)
# Obtain slopes
    #ranef(Temp_all_1)
    #fixef(Temp_all_1)
    #coef(Temp_all_1)$Month
    #coef(Temp_all_1)$Zone
  m.lst <- lstrends(Temp_all_1, "Zone", var="Year")
  m.lst
##  Zone        Year.trend     SE   df lower.CL upper.CL
##  Inshore        -0.0109 0.0331 1191 -0.07585   0.0541
##  Mid channel     0.0637 0.0341 1191 -0.00319   0.1307
##  Offshore        0.0868 0.0313 1192  0.02536   0.1483
##  Oceanic         0.0983 0.0473 1191  0.00549   0.1911
## 
## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95
  pairs(m.lst)
##  contrast               estimate     SE   df t.ratio p.value
##  Inshore - Mid channel   -0.0746 0.0435 1190  -1.714  0.3169
##  Inshore - Offshore      -0.0977 0.0414 1190  -2.357  0.0860
##  Inshore - Oceanic       -0.1092 0.0546 1190  -1.998  0.1891
##  Mid channel - Offshore  -0.0231 0.0423 1190  -0.546  0.9476
##  Mid channel - Oceanic   -0.0345 0.0552 1190  -0.625  0.9240
##  Offshore - Oceanic      -0.0115 0.0536 1190  -0.214  0.9965
## 
## Degrees-of-freedom method: kenward-roger 
## P value adjustment: tukey method for comparing a family of 4 estimates

Inshore

# Inshore Omega
  hist(Trends.inshore$Temperature_C)

  shapiro.test(Trends.inshore$Aragonite_Sat_W) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.inshore$Aragonite_Sat_W
## W = 0.98784, p-value = 0.005584
  Temp_in_0<-lmer(Temperature_C~Year * Sub_region + (1|Month)+
                                    #(1|Zone)+             
                                    (1|SiteID), data=Trends.inshore)
  
  #summary(Omega_in_0)
  #summary(Omega_in_1)    
  #anova(Omega_in_0, Omega_in_1)
  #step(Omega_in_1)
  
  anova(Temp_in_0)
  ranova(Temp_in_0)
  step(Temp_in_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -646.07 1314.2                         
## (1 | SiteID)          1   10 -646.07 1312.2   0.00  1          1    
## (1 | Month)           0    9 -920.58 1859.2 549.02  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value Pr(>F)
## Year:Sub_region          1 7.9739 2.65798     3 326.96  1.3232 0.2667
## Year                     2 0.3938 0.39378     1 333.34  0.1955 0.6587
## Sub_region               3 8.5028 2.83425     3 331.00  1.4098 0.2398
## 
## Model found:
## Temperature_C ~ (1 | Month)
  Temp_in<-lmer(Temperature_C ~ (1 | Month),
                 data=Trends.inshore)
  ranova(Temp_in)
  summary(Temp_in)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Temperature_C ~ (1 | Month)
##    Data: Trends.inshore
## 
## REML criterion at convergence: 1283.2
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -6.1959 -0.5001  0.0160  0.5502  2.7613 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 12.041   3.47    
##  Residual              2.018   1.42    
## Number of obs: 346, groups:  Month, 12
## 
## Fixed effects:
##             Estimate Std. Error     df t value Pr(>|t|)    
## (Intercept)   26.980      1.005 10.975   26.85 2.32e-11 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  plot(Temp_in)

  qqnorm(resid(Temp_in))

  acf(resid(Temp_in), main="acf(resid(Temperature Inshore))")

Mid channel

hist(Trends.midchanel$Temperature_C)

shapiro.test(Trends.midchanel$Temperature_C)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.midchanel$Temperature_C
## W = 0.97295, p-value = 1.028e-05
Temp_mc_0<-lmer(Temperature_C~Year * Sub_region + (1|Month) + 
                                  #(1|Zone)+             
                                  (1|SiteID), data=Trends.midchanel)

anova(Temp_mc_0)
ranova(Temp_mc_0)
step(Temp_mc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -505.89 1033.8                         
## (1 | SiteID)          1   10 -505.89 1031.8   0.00  1          1    
## (1 | Month)           0    9 -792.87 1603.7 573.94  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value  Pr(>F)  
## Year:Sub_region          1 1.0244  0.3415     3 300.95  0.3126 0.81631  
## Sub_region               2 4.1315  1.3772     3 303.98  1.2692 0.28504  
## Year                     3 3.2289  3.2289     1 309.49  2.9679 0.08593 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## Temperature_C ~ (1 | Month)
Temp_mc<-lmer(Temperature_C ~ (1 | Month),
               data = Trends.midchanel)
  summary(Temp_mc) 
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Temperature_C ~ (1 | Month)
##    Data: Trends.midchanel
## 
## REML criterion at convergence: 998.5
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -5.0528 -0.5494 -0.0563  0.4968  2.7791 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 8.554    2.925   
##  Residual             1.096    1.047   
## Number of obs: 320, groups:  Month, 12
## 
## Fixed effects:
##             Estimate Std. Error      df t value Pr(>|t|)    
## (Intercept)  27.2397     0.8466 10.9778   32.18 3.24e-12 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  plot(Temp_mc)

  qqnorm(resid(Temp_mc))

  acf(resid(Temp_mc), main="acf(resid(Omega mid Channel))")

Offshore

hist(Trends.offshore$Temperature_C)

shapiro.test(Trends.offshore$Temperature_C)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.offshore$Temperature_C
## W = 0.96684, p-value = 8.65e-08
Temp_of_0<-lmer(Temperature_C~Year * Sub_region + 
               (1|Month) + (1|SiteID),
               data=Trends.offshore)
#summary(Omega_of_0)    
anova(Temp_of_0)
ranova(Temp_of_0)
step(Temp_of_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -490.60 1003.2                         
## (1 | SiteID)          1   10 -490.60 1001.2   0.00  1          1    
## (1 | Month)           0    9 -906.96 1831.9 832.71  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value   Pr(>F)   
## Year:Sub_region          1 2.0849  0.6950     3 374.98  1.2340 0.297079   
## Sub_region               2 3.1704  1.0568     3 377.98  1.8731 0.133631   
## Year                     0 4.4221  4.4221     1 382.67  7.7841 0.005535 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## Temperature_C ~ Year + (1 | Month)
Temp_of<-lmer(Temperature_C ~ (1 | Month), 
               data =Trends.offshore)
  summary(Temp_of)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Temperature_C ~ (1 | Month)
##    Data: Trends.offshore
## 
## REML criterion at convergence: 971.3
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.2993 -0.6222 -0.0863  0.4675  3.2857 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 6.7781   2.6035  
##  Residual             0.5789   0.7608  
## Number of obs: 394, groups:  Month, 12
## 
## Fixed effects:
##             Estimate Std. Error      df t value Pr(>|t|)    
## (Intercept)  27.2617     0.7527 10.9783   36.22 8.92e-13 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  plot(Temp_of)

  qqnorm(resid(Temp_of))

  acf(resid(Temp_of), main="acf(resid(Omega offshore))")  

Oceanic

hist(Trends.ocean$Temperature_C)

shapiro.test(Trends.ocean$Temperature_C)# Normality NOT rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.ocean$Temperature_C
## W = 0.9499, p-value = 3.415e-05
Temp_oc_0<-lmer(Temperature_C ~ Year * Sub_region + 
               (1 | Month)+ (1|SiteID),
               data=Trends.ocean)

  anova(Temp_oc_0)
  ranova(Temp_oc_0)
  step(Temp_oc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                     9 -199.89 417.79                         
## (1 | SiteID)          1    8 -199.89 415.79   0.00  1          1    
## (1 | Month)           0    7 -329.75 673.50 259.71  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value Pr(>F)
## Year:Sub_region          1 0.38581 0.19291     2 131.95  0.3520 0.7039
## Sub_region               2 0.09723 0.04861     2 133.93  0.0896 0.9143
## Year                     3 0.58385 0.58385     1 137.66  1.0907 0.2981
## 
## Model found:
## Temperature_C ~ (1 | Month)
Temp_oc<-lmer(Temperature_C ~(1 | Month), data = Trends.ocean)
  summary(Temp_oc)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Temperature_C ~ (1 | Month)
##    Data: Trends.ocean
## 
## REML criterion at convergence: 385.9
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.2127 -0.5855 -0.1571  0.5743  2.9673 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 5.6880   2.3849  
##  Residual             0.5368   0.7327  
## Number of obs: 149, groups:  Month, 12
## 
## Fixed effects:
##             Estimate Std. Error      df t value Pr(>|t|)    
## (Intercept)  27.3896     0.6915 10.9174   39.61 3.81e-13 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  ranova(Temp_oc)
  plot(Temp_oc)

  qqnorm(resid(Temp_oc))

  acf(resid(Temp_oc), main="acf(resid(Temp_oc open))")

Models summary

Complete models

# ANOVAs
    # Convert ANOVA results into dataframes allows for easier name manipulation
    av.Temp_in_0 <- data.frame (anova(Temp_in_0))
    av.Temp_mc_0 <- data.frame (anova(Temp_mc_0) )
    av.Temp_of_0 <- data.frame (anova(Temp_of_0))
    av.Temp_oc_0 <- data.frame (anova(Temp_oc_0))
    
    # Putting all into one dataframe/table
    anova_Temp_0 <- data.frame(cbind
                    (c("Year", "Sub_region", "Year:Sub_region", 
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region"), 
                                      rbind(av.Temp_in_0, av.Temp_mc_0,
                                            av.Temp_of_0, av.Temp_oc_0))) 
    colnames(anova_Temp_0) <- c("", "Sum Sq", "Mean Sq", "N Df" , "D Df",
                                     "F value", "Pr(>F)")
    row.names(anova_Temp_0) <- NULL
    
    # create HTML table using kableExtra
    anova_Temp_0 %>% kable("html", digits=2, 
        caption="Initial temperature models fixed factors: Year*Region") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Omega inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "Omega mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "Omega offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "Omega ocean", 10, 12)  
Initial temperature models fixed factors: Year*Region
Sum Sq Mean Sq N Df D Df F value Pr(>F)
Omega inshore
Year 0.67 0.67 1 330.26 0.34 0.56
Sub_region 7.97 2.66 3 326.98 1.32 0.27
Year:Sub_region 7.97 2.66 3 326.98 1.32 0.27
Omega mid-channel
Year 3.22 3.22 1 303.39 2.95 0.09
Sub_region 1.03 0.34 3 300.98 0.31 0.82
Year:Sub_region 1.02 0.34 3 300.98 0.31 0.82
Omega offshore
Year 5.35 5.35 1 376.55 9.51 0.00
Sub_region 2.08 0.69 3 374.95 1.23 0.30
Year:Sub_region 2.08 0.69 3 374.95 1.23 0.30
Omega ocean
Year 0.32 0.32 1 133.59 0.58 0.45
Sub_region 0.39 0.19 2 131.94 0.35 0.70
Year:Sub_region 0.39 0.19 2 131.94 0.35 0.70
# R-ANOVAs    
    rav.Temp_in_0 <- data.frame (ranova(Temp_in_0))
    rav.Temp_mc_0 <- data.frame (ranova(Temp_mc_0) )
    rav.Temp_of_0 <- data.frame (ranova(Temp_of_0))
    rav.Temp_oc_0 <- data.frame (ranova(Temp_oc_0))
    
    # Putting all into one dataframe/table
    ranova_Temp_0 <- data.frame(cbind
                    (c("<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)"), 
                      rbind(rav.Temp_in_0, rav.Temp_mc_0,
                            rav.Temp_of_0, rav.Temp_oc_0))) 
    colnames(ranova_Temp_0) <- c("", "npar", "logLik", "AIC" , "LRT",
                                     "DF", "Pr(>Chi Sq)")
    row.names(ranova_Temp_0) <- NULL
    
    # create HTML table using kableExtra
    ranova_Temp_0 %>% kable("html", digits=2,
         caption="Initial temperature models random factors: Month+Station") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Omega inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "Omega mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "Omega offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "Omega ocean", 10, 12)  
Initial temperature models random factors: Month+Station
npar logLik AIC LRT DF Pr(>Chi Sq)
Omega inshore
<none> 11 -646.07 1314.15
(1 | Month) 10 -920.58 1861.16 549.02 1 0
(1 | SiteID) 10 -646.07 1312.15 0.00 1 1
Omega mid-channel
<none> 11 -505.89 1033.79
(1 | Month) 10 -792.87 1605.73 573.94 1 0
(1 | SiteID) 10 -505.89 1031.79 0.00 1 1
Omega offshore
<none> 11 -490.60 1003.21
(1 | Month) 10 -906.96 1833.91 832.71 1 0
(1 | SiteID) 10 -490.60 1001.21 0.00 1 1
Omega ocean
<none> 9 -199.89 417.79
(1 | Month) 8 -329.75 675.50 259.71 1 0
(1 | SiteID) 8 -199.89 415.79 0.00 1 1
Temp_models_0<-list("Inshore" = Temp_in_0, 
                   "Mid channel" = Temp_mc_0, 
                   "Offshore" = Temp_of_0, 
                   "Ocean" = Temp_oc_0)
modelsummary(Temp_models_0, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'Initial temperature model outputs (all factors)',
             coef_map=factor_order)
Initial temperature model outputs (all factors)
Inshore Mid channel Offshore Ocean
Year 0.104 0.092 0.133** −0.010
(0.088) (0.066) (0.047) (0.072)
Intercept −183.974 −157.964 −241.064* 47.800
(176.787) (132.574) (94.175) (144.340)
Upper Keys 52.495 88.854 133.838
(223.284) (181.158) (116.203)
Middle Keys 185.262 13.045 134.123 −102.725
(216.610) (160.336) (115.108) (163.475)
Lower Keys 382.245+ 128.562 209.830+ −137.042
(217.219) (161.197) (109.249) (163.871)
Num.Obs. 346 320 394 149
R2 Marg. 0.024 0.029 0.053 0.017
R2 Cond.
AIC 1314.1 1033.8 1003.2 417.8
BIC 1356.5 1075.2 1046.9 444.8
RMSE 1.38 1.01 0.73 0.70
+ p
#modelsummary(Omega_models, estimate = "p.value")

Models with non-significant factors removed

Temp_models<-list("Inshore" = Temp_in, 
                   "Mid channel" = Temp_mc, 
                   "Offshore" = Temp_of, 
                   "Ocean" = Temp_oc)
modelsummary(Temp_models, stars = TRUE, 
            #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'Final Omega model outputs (dropped factors)',
             coef_map=factor_order)
Final Omega model outputs (dropped factors)
Inshore Mid channel Offshore Ocean
Intercept 26.980*** 27.240*** 27.262*** 27.390***
(1.005) (0.847) (0.753) (0.692)
Num.Obs. 346 320 394 149
R2 Marg. 0.000 0.000 0.000 0.000
R2 Cond. 0.856 0.886 0.921 0.914
AIC 1289.2 1004.5 977.3 391.9
BIC 1300.8 1015.8 989.2 400.9
ICC 0.9 0.9 0.9 0.9
RMSE 1.40 1.03 0.75 0.70
+ p
#modelsummary(Temp_models, estimate = "p.value")

DIC-All

## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.data$DIC_umol_kg
## W = 0.89265, p-value < 2.2e-16

## Model with all data
DIC_all_o<-lmer(DIC_umol_kg~Year * Zone * Sub_region + (1|Month)+           
                                    (1|SiteID), data=Trends.data)
  step(DIC_all_o)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik   AIC    LRT Df Pr(>Chisq)    
## <none>                    33 -6447.7 12962                         
## (1 | Month)           0   32 -6634.8 13334 374.08  1    < 2e-16 ***
## (1 | SiteID)          0   32 -6449.6 12963   3.65  1    0.05618 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                      Eliminated Sum Sq Mean Sq NumDF   DenDF F value  Pr(>F)  
## Year:Zone:Sub_region          1  13180  1647.5     8 1137.17  0.5432 0.82440  
## Year:Zone                     2   2471   823.5     3 1144.91  0.2724 0.84533  
## Year:Sub_region               0  27593  9197.6     3 1147.73  3.0482 0.02783 *
## Zone:Sub_region               0  73938  9242.3     8   24.42  3.0630 0.01557 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## DIC_umol_kg ~ Year + Zone + Sub_region + (1 | Month) + (1 | SiteID) + Year:Sub_region + Zone:Sub_region
DIC_all_1<-lmer(DIC_umol_kg ~ Year + Zone + Sub_region + 
                  (1 | Month) + (1 | SiteID) + 
                  Year:Sub_region + Zone:Sub_region, data=Trends.data)

    summary(DIC_all_1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: DIC_umol_kg ~ Year + Zone + Sub_region + (1 | Month) + (1 | SiteID) +  
##     Year:Sub_region + Zone:Sub_region
##    Data: Trends.data
## 
## REML criterion at convergence: 12950.6
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.6604 -0.4911 -0.0099  0.5799  4.7194 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  SiteID   (Intercept)   64.52   8.033  
##  Month    (Intercept) 1524.91  39.050  
##  Residual             3017.40  54.931  
## Number of obs: 1199, groups:  SiteID, 38; Month, 12
## 
## Fixed effects:
##                                Estimate Std. Error         df t value Pr(>|t|)
## (Intercept)                   3123.0373  3948.1445  1154.2529   0.791 0.429098
## Year                            -0.5305     1.9565  1154.2299  -0.271 0.786329
## ZoneMid channel                 -3.7677    12.4904    22.7085  -0.302 0.765664
## ZoneOffshore                    -3.2992    12.4617    22.5030  -0.265 0.793612
## ZoneOceanic                     63.6729    11.6436    24.6719   5.468 1.16e-05
## Sub_regionUK                  3844.5160  4962.5575  1147.9226   0.775 0.438674
## Sub_regionMK                 -7628.6766  4679.6966  1146.6032  -1.630 0.103341
## Sub_regionLK                  2155.8553  4643.0911  1146.8134   0.464 0.642510
## Year:Sub_regionUK               -1.9153     2.4594  1147.9150  -0.779 0.436292
## Year:Sub_regionMK                3.7565     2.3191  1146.5903   1.620 0.105551
## Year:Sub_regionLK               -1.1025     2.3010  1146.8012  -0.479 0.631944
## ZoneMid channel:Sub_regionUK    10.6945    17.2541    24.5072   0.620 0.541094
## ZoneOffshore:Sub_regionUK       15.4035    16.2952    23.6208   0.945 0.354089
## ZoneOceanic:Sub_regionUK       -53.5128    19.2986    27.5410  -2.773 0.009851
## ZoneMid channel:Sub_regionMK    26.2411    16.2049    23.1626   1.619 0.118912
## ZoneOffshore:Sub_regionMK       40.0185    16.1733    22.9838   2.474 0.021161
## ZoneOceanic:Sub_regionMK       -18.9579    16.4713    24.7115  -1.151 0.260762
## ZoneMid channel:Sub_regionLK    43.2103    16.1546    22.8690   2.675 0.013568
## ZoneOffshore:Sub_regionLK       65.9258    15.7197    22.7182   4.194 0.000355
##                                 
## (Intercept)                     
## Year                            
## ZoneMid channel                 
## ZoneOffshore                    
## ZoneOceanic                  ***
## Sub_regionUK                    
## Sub_regionMK                    
## Sub_regionLK                    
## Year:Sub_regionUK               
## Year:Sub_regionMK               
## Year:Sub_regionLK               
## ZoneMid channel:Sub_regionUK    
## ZoneOffshore:Sub_regionUK       
## ZoneOceanic:Sub_regionUK     ** 
## ZoneMid channel:Sub_regionMK    
## ZoneOffshore:Sub_regionMK    *  
## ZoneOceanic:Sub_regionMK        
## ZoneMid channel:Sub_regionLK *  
## ZoneOffshore:Sub_regionLK    ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## fit warnings:
## fixed-effect model matrix is rank deficient so dropping 1 column / coefficient
    anova(DIC_all_1)
    ranova(DIC_all_1)
# Obtain slopes
#     ranef(DIC_all_1)
#     fixef(DIC_all_1)
#     coef(DIC_all_1)$Month
#     coef(DIC_all_1)$Zone
    
  m.lst <- lstrends(DIC_all_1, "Sub_region", var="Year")
  m.lst
##  Sub_region Year.trend   SE   df lower.CL upper.CL
##  BB             -0.531 1.96 1154   -4.372     3.31
##  UK             -2.446 1.73 1159   -5.831     0.94
##  MK              3.226 1.51 1157    0.258     6.19
##  LK             -1.633 1.50 1158   -4.574     1.31
## 
## Results are averaged over the levels of: Zone 
## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95
  #pairs(m.lst)

Inshore

# Inshore DIC
  hist(Trends.inshore$DIC_umol_kg)

  shapiro.test(Trends.inshore$DIC_umol_kg) # Normality NOT rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.inshore$DIC_umol_kg
## W = 0.99743, p-value = 0.8723
  DIC_in_0<-lmer(DIC_umol_kg~Year * Sub_region + (1|Month)+
                                    #(1|Zone)+             
                                    (1|SiteID), data=Trends.inshore)
  
  DIC_in_1<-lmer(DIC_umol_kg~Year * Sub_region * Season +
                                    (1|Month)+
                                    #(1|Zone)+             
                                    (1|SiteID), data=Trends.inshore)
  
  summary(DIC_in_0)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: DIC_umol_kg ~ Year * Sub_region + (1 | Month) + (1 | SiteID)
##    Data: Trends.inshore
## 
## REML criterion at convergence: 3889.6
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -3.15665 -0.60937 -0.00018  0.65128  2.88050 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 6890.9   83.01   
##  SiteID   (Intercept)  263.8   16.24   
##  Residual             4793.0   69.23   
## Number of obs: 344, groups:  Month, 12; SiteID, 11
## 
## Fixed effects:
##                     Estimate Std. Error         df t value Pr(>|t|)
## (Intercept)        4.485e+03  8.617e+03  3.218e+02   0.521    0.603
## Year              -1.204e+00  4.270e+00  3.217e+02  -0.282    0.778
## Sub_regionUK       2.736e+03  1.091e+04  3.185e+02   0.251    0.802
## Sub_regionMK      -1.705e+04  1.058e+04  3.183e+02  -1.611    0.108
## Sub_regionLK       1.546e+03  1.066e+04  3.183e+02   0.145    0.885
## Year:Sub_regionUK -1.364e+00  5.408e+00  3.185e+02  -0.252    0.801
## Year:Sub_regionMK  8.427e+00  5.245e+00  3.183e+02   1.607    0.109
## Year:Sub_regionLK -8.012e-01  5.282e+00  3.183e+02  -0.152    0.880
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK Sb_rLK Y:S_UK Y:S_MK
## Year        -1.000                                          
## Sub_reginUK -0.700  0.700                                   
## Sub_reginMK -0.723  0.723  0.569                            
## Sub_reginLK -0.709  0.709  0.563  0.580                     
## Yr:Sb_rgnUK  0.700 -0.700 -1.000 -0.569 -0.563              
## Yr:Sb_rgnMK  0.723 -0.723 -0.569 -1.000 -0.580  0.569       
## Yr:Sb_rgnLK  0.709 -0.709 -0.563 -0.580 -1.000  0.563  0.580
  summary(DIC_in_1)    
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: DIC_umol_kg ~ Year * Sub_region * Season + (1 | Month) + (1 |  
##     SiteID)
##    Data: Trends.inshore
## 
## REML criterion at convergence: 3633.9
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -3.15765 -0.59852 -0.01445  0.61366  2.74407 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept)  639.7   25.29   
##  SiteID   (Intercept)  241.6   15.54   
##  Residual             4296.7   65.55   
## Number of obs: 344, groups:  Month, 12; SiteID, 11
## 
## Fixed effects:
##                                  Estimate Std. Error         df t value
## (Intercept)                     4.748e+03  2.063e+04  2.842e+02   0.230
## Year                           -1.309e+00  1.022e+01  2.843e+02  -0.128
## Sub_regionUK                   -1.699e+04  2.616e+04  2.990e+02  -0.649
## Sub_regionMK                   -3.380e+04  2.531e+04  2.971e+02  -1.335
## Sub_regionLK                    1.302e+04  2.516e+04  2.973e+02   0.518
## SeasonSpring                   -2.804e+04  2.532e+04  2.991e+02  -1.108
## SeasonSummer                    1.545e+04  2.623e+04  2.966e+02   0.589
## SeasonFall                      2.152e+04  2.604e+04  2.783e+02   0.827
## Year:Sub_regionUK               8.415e+00  1.296e+01  2.990e+02   0.649
## Year:Sub_regionMK               1.675e+01  1.254e+01  2.971e+02   1.336
## Year:Sub_regionLK              -6.470e+00  1.247e+01  2.973e+02  -0.519
## Year:SeasonSpring               1.383e+01  1.255e+01  2.991e+02   1.102
## Year:SeasonSummer              -7.700e+00  1.300e+01  2.966e+02  -0.592
## Year:SeasonFall                -1.066e+01  1.290e+01  2.783e+02  -0.826
## Sub_regionUK:SeasonSpring       4.111e+04  3.218e+04  2.985e+02   1.278
## Sub_regionMK:SeasonSpring       5.576e+04  3.149e+04  2.973e+02   1.771
## Sub_regionLK:SeasonSpring      -1.409e+04  3.160e+04  2.977e+02  -0.446
## Sub_regionUK:SeasonSummer       1.158e+03  3.309e+04  2.988e+02   0.035
## Sub_regionMK:SeasonSummer       1.537e+04  3.242e+04  2.975e+02   0.474
## Sub_regionLK:SeasonSummer      -1.965e+04  3.330e+04  2.996e+02  -0.590
## Sub_regionUK:SeasonFall         3.872e+04  3.368e+04  2.990e+02   1.150
## Sub_regionMK:SeasonFall         5.532e+03  3.189e+04  2.976e+02   0.173
## Sub_regionLK:SeasonFall        -5.455e+03  3.161e+04  2.976e+02  -0.173
## Year:Sub_regionUK:SeasonSpring -2.039e+01  1.595e+01  2.985e+02  -1.279
## Year:Sub_regionMK:SeasonSpring -2.767e+01  1.561e+01  2.973e+02  -1.773
## Year:Sub_regionLK:SeasonSpring  6.970e+00  1.566e+01  2.977e+02   0.445
## Year:Sub_regionUK:SeasonSummer -5.765e-01  1.640e+01  2.988e+02  -0.035
## Year:Sub_regionMK:SeasonSummer -7.676e+00  1.607e+01  2.975e+02  -0.478
## Year:Sub_regionLK:SeasonSummer  9.702e+00  1.651e+01  2.996e+02   0.588
## Year:Sub_regionUK:SeasonFall   -1.919e+01  1.669e+01  2.990e+02  -1.150
## Year:Sub_regionMK:SeasonFall   -2.764e+00  1.580e+01  2.976e+02  -0.175
## Year:Sub_regionLK:SeasonFall    2.673e+00  1.566e+01  2.976e+02   0.171
##                                Pr(>|t|)  
## (Intercept)                      0.8182  
## Year                             0.8982  
## Sub_regionUK                     0.5167  
## Sub_regionMK                     0.1829  
## Sub_regionLK                     0.6051  
## SeasonSpring                     0.2689  
## SeasonSummer                     0.5562  
## SeasonFall                       0.4092  
## Year:Sub_regionUK                0.5168  
## Year:Sub_regionMK                0.1827  
## Year:Sub_regionLK                0.6043  
## Year:SeasonSpring                0.2713  
## Year:SeasonSummer                0.5540  
## Year:SeasonFall                  0.4096  
## Sub_regionUK:SeasonSpring        0.2023  
## Sub_regionMK:SeasonSpring        0.0776 .
## Sub_regionLK:SeasonSpring        0.6561  
## Sub_regionUK:SeasonSummer        0.9721  
## Sub_regionMK:SeasonSummer        0.6358  
## Sub_regionLK:SeasonSummer        0.5556  
## Sub_regionUK:SeasonFall          0.2512  
## Sub_regionMK:SeasonFall          0.8624  
## Sub_regionLK:SeasonFall          0.8631  
## Year:Sub_regionUK:SeasonSpring   0.2019  
## Year:Sub_regionMK:SeasonSpring   0.0773 .
## Year:Sub_regionLK:SeasonSpring   0.6566  
## Year:Sub_regionUK:SeasonSummer   0.9720  
## Year:Sub_regionMK:SeasonSummer   0.6332  
## Year:Sub_regionLK:SeasonSummer   0.5571  
## Year:Sub_regionUK:SeasonFall     0.2512  
## Year:Sub_regionMK:SeasonFall     0.8613  
## Year:Sub_regionLK:SeasonFall     0.8646  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  anova(DIC_in_0, DIC_in_1)
  step(DIC_in_1)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC     LRT Df Pr(>Chisq)    
## <none>                    35 -1816.9 3703.9                          
## (1 | Month)           0   34 -1825.4 3718.9 17.0195  1    3.7e-05 ***
## (1 | SiteID)          0   34 -1819.5 3707.1  5.2456  1      0.022 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                        Eliminated Sum Sq Mean Sq NumDF  DenDF F value    Pr(>F)
## Year:Sub_region:Season          1  56077  6230.7     9 299.17  1.4501   0.16612
## Year:Sub_region                 2  15025  5008.3     3 308.33  1.1508   0.32881
## Year:Season                     0  43951 14650.2     3 140.19  3.3603   0.02063
## Sub_region:Season               0 155810 17312.2     9 311.18  3.9709 8.217e-05
##                           
## Year:Sub_region:Season    
## Year:Sub_region           
## Year:Season            *  
## Sub_region:Season      ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## DIC_umol_kg ~ Year + Sub_region + Season + (1 | Month) + (1 | SiteID) + Year:Season + Sub_region:Season
  anova(DIC_in_1)
  ranova(DIC_in_1)
  step(DIC_in_1)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC     LRT Df Pr(>Chisq)    
## <none>                    35 -1816.9 3703.9                          
## (1 | Month)           0   34 -1825.4 3718.9 17.0195  1    3.7e-05 ***
## (1 | SiteID)          0   34 -1819.5 3707.1  5.2456  1      0.022 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                        Eliminated Sum Sq Mean Sq NumDF  DenDF F value    Pr(>F)
## Year:Sub_region:Season          1  56077  6230.7     9 299.17  1.4501   0.16612
## Year:Sub_region                 2  15025  5008.3     3 308.33  1.1508   0.32881
## Year:Season                     0  43951 14650.2     3 140.19  3.3603   0.02063
## Sub_region:Season               0 155810 17312.2     9 311.18  3.9709 8.217e-05
##                           
## Year:Sub_region:Season    
## Year:Sub_region           
## Year:Season            *  
## Sub_region:Season      ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## DIC_umol_kg ~ Year + Sub_region + Season + (1 | Month) + (1 | SiteID) + Year:Season + Sub_region:Season
  DIC_in<-lmer(DIC_umol_kg ~ Year + Sub_region +
               (1 | Month) + (1 | SiteID),
                            data=Trends.inshore)
  anova(DIC_in)
  summary(DIC_in)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: DIC_umol_kg ~ Year + Sub_region + (1 | Month) + (1 | SiteID)
##    Data: Trends.inshore
## 
## REML criterion at convergence: 3909.6
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.4187 -0.6488 -0.0022  0.6496  2.7936 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 6878.9   82.94   
##  SiteID   (Intercept)  261.7   16.18   
##  Residual             4829.2   69.49   
## Number of obs: 344, groups:  Month, 12; SiteID, 11
## 
## Fixed effects:
##               Estimate Std. Error        df t value Pr(>|t|)   
## (Intercept)   675.9450  4678.1870  331.5171   0.144  0.88520   
## Year            0.6833     2.3182  331.5036   0.295  0.76838   
## Sub_regionUK  -16.4631    18.5970    7.1538  -0.885  0.40479   
## Sub_regionMK  -46.2885    18.5087    7.0228  -2.501  0.04083 * 
## Sub_regionLK  -70.7519    18.4783    6.9754  -3.829  0.00651 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.026  0.024              
## Sub_reginMK -0.013  0.010  0.590       
## Sub_reginLK -0.023  0.021  0.591  0.595
  plot(DIC_in)

  qqnorm(resid(DIC_in))

  acf(resid(DIC_in), main="acf(resid(DIC Inshore))")

  DIC_in.emmc<-emmeans(DIC_in, ~Sub_region)
    DIC_in.emmc<-multcomp::cld(DIC_in.emmc)
    #DIC_in.emmc<-as.data.frame(DIC_in.emmc[complete.cases(DIC_in.emmc),])
    DIC_in.emmc<-DIC_in.emmc[order(DIC_in.emmc$Sub_region),]
    DIC_in.emmc
  #write.csv(Temp_in.emmc, "FLK_results/Model_9_LTpH_POST.csv")
    round(DIC_in.emmc$emmean, digits = 2)
## [1] 2054.61 2038.15 2008.33 1983.86
    #anova(DIC_in)
    #ranova(DIC_in)
# Create a new data frame for independent variables  
  In_Newdata<-expand.grid(Sub_region=unique(Trends.inshore$Sub_region),
                          Year=seq((min(Trends.inshore$Year)-0),
                                   (max(Trends.inshore$Year)+1)))

  In_DIC_Pred <- predict(DIC_in, newdata=In_Newdata, 
                         re.form=NA, level=0, asList = FALSE)
  
  In_DIC_Pred <-cbind(In_Newdata, In_DIC_Pred)
  In_DIC_Pred$Date<-as.Date(as.character(In_DIC_Pred$Year), format = "%Y")
  
  
# Plot raw data point and fitted model 
  
  In_DIC_Modeled<-Long_plot2+ #facet_grid(~Zone)+
     scale_y_continuous(#limits = c(0,6),
                       name=(expression(~DIC[Ar])),
                       #limits = c(2.3, 5.2),
                       #breaks = seq(0, 10, 0.5),  
                       expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.inshore, 
                               aes(y=DIC_umol_kg, x=Date, 
                                  #fill = Sub_region), 
                                  colour = Sub_region), 
                               alpha=0.5, size=0.5, shape=21)+
      geom_line(data=In_DIC_Pred, aes(y = In_DIC_Pred,
                                      x=Date, colour = Sub_region), linetype=2, size=1) 
  In_DIC_Modeled

Mid channel

hist(Trends.midchanel$DIC_umol_kg)

shapiro.test(Trends.midchanel$DIC_umol_kg)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.midchanel$DIC_umol_kg
## W = 0.93354, p-value = 1.006e-10
DIC_mc_0<-lmer(DIC_umol_kg~Year * Sub_region + (1|Month) + 
                                  #(1|Zone)+             
                                  (1|SiteID), data=Trends.midchanel)

# DIC_mc_1<-lmer(DIC_umol_kg~Year * Sub_region * Season +
#                                     #(1|Zone)+             
#                                     (1|SiteID), data=Trends.midchanel)

#summary(DIC_mc_0)    
#summary(DIC_mc_1)  

anova(DIC_mc_0)
#anova(DIC_mc_1)
#anova(DIC_mc_0, DIC_mc_1)
ranova(DIC_mc_0)
step(DIC_mc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC     LRT Df Pr(>Chisq)    
## <none>                    11 -1658.0 3338.0                          
## (1 | SiteID)          1   10 -1658.7 3337.3   1.392  1     0.2381    
## (1 | Month)           0    9 -1723.8 3465.6 130.301  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value   Pr(>F)   
## Year:Sub_region          1  8969.4  2989.8     3 298.83  1.4612 0.225205   
## Year                     2  2116.7  2116.7     1 312.94  1.0294 0.311081   
## Sub_region               0 29687.4  9895.8     3 303.09  4.8018 0.002777 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## DIC_umol_kg ~ Sub_region + (1 | Month)
DIC_mc<-lmer(DIC_umol_kg ~ Year + Sub_region + (1 | Month),
               data = Trends.midchanel)
  summary(DIC_mc) 
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: DIC_umol_kg ~ Year + Sub_region + (1 | Month)
##    Data: Trends.midchanel
## 
## REML criterion at convergence: 3334
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.3673 -0.4419  0.0603  0.5355  3.9086 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 1701     41.24   
##  Residual             2056     45.35   
## Number of obs: 318, groups:  Month, 12
## 
## Fixed effects:
##              Estimate Std. Error       df t value Pr(>|t|)    
## (Intercept)  5217.407   3124.726  312.935   1.670 0.095975 .  
## Year           -1.571      1.548  312.936  -1.015 0.311081    
## Sub_regionUK   -8.845      8.252  301.917  -1.072 0.284641    
## Sub_regionMK  -21.745      7.279  301.853  -2.987 0.003045 ** 
## Sub_regionLK  -24.605      7.267  301.979  -3.386 0.000803 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.019  0.018              
## Sub_reginMK -0.004  0.003  0.528       
## Sub_reginLK -0.025  0.024  0.531  0.602
  anova(DIC_mc) 
  plot(DIC_mc)

  qqnorm(resid(DIC_mc))

  acf(resid(DIC_mc), main="acf(resid(DIC mid Channel))")  

  Temp_md.emmc<-emmeans(DIC_mc, ~Sub_region+Year)
    Temp_md.emmc<-multcomp::cld(Temp_md.emmc)
    #Temp_in.emmc<-as.data.frame(Temp_in.emmc[complete.cases(Temp_in.emmc),])
    Temp_md.emmc<-Temp_md.emmc[order(Temp_md.emmc$Sub_region),]
    Temp_md.emmc
  #write.csv(Temp_md.emmc, "FLK_results/Model_10_LTpH_POST.csv")
# Create a new data frame for independent variables  
  Mc_Newdata<-expand.grid(Zone=unique(Trends.midchanel$Zone),
                                Sub_region=unique(Trends.midchanel$Sub_region),
                          Year=seq((min(Trends.midchanel$Year)-0), (max(Trends.midchanel$Year)+1)))
  Mc_DIC_Pred <- predict(DIC_mc, newdata=Mc_Newdata, re.form=NA, level=0, asList = FALSE)
  
  Mc_DIC_Pred <-cbind(Mc_Newdata, Mc_DIC_Pred)
  Mc_DIC_Pred$Date<-as.Date(as.character(Mc_DIC_Pred$Year), format = "%Y")
  
  
# Model summary for labels
  slope<-round(
      summary(DIC_mc)$coefficients["Year", "Estimate"], digits = 3)
  ys <- max(Trends.midchanel$DIC_umol_kg, na.rm =T)+ 0.3

# Plot raw data point and fitted model 
  plot_label <- sprintf("\"\" ~ DIC[Ar] == %0.3f", slope)
  plot_label2 <- expression("Year^-1")
  
  Mc_DIC_Modeled<-Long_plot2+ #facet_grid(~Zone)+
     scale_y_continuous(#limits = c(15,40),
                       #name=(expression("Aragonite saturation state" ~(DIC[Ar]))),
                       name=(expression(~DIC[Ar])),
                       limits = c(2.3, 5.2),
                       breaks = seq(0, 10, 0.5),  
                       expand = c(0.02, 0.02)) +
    
      geom_jitter(data=Trends.midchanel, 
                               aes(y=DIC_umol_kg, x=Date, 
                                  #fill = Sub_region), 
                                  colour = Sub_region), 
                               alpha=0.5, size=0.5, shape=23)+
      geom_line(data=Mc_DIC_Pred, aes(y = Mc_DIC_Pred,
                                      x=Date, colour = Sub_region), linetype=1, size=1)+
      # geom_text(data = slope, aes(x = xs, y = ys,
      #                       label = (paste("~DIC[Ar]", "=", 
      #                                     slope, "Year ^-1"))), size=10)
      annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
               #label = expression("~DIC[Ar] == -0.015** ~Year ^-1"), 
               label =paste0(as.character(plot_label, plot_label2, sep = " ")),
               size=4)
  Mc_DIC_Modeled

Offshore

hist(Trends.offshore$DIC_umol_kg)

shapiro.test(Trends.offshore$DIC_umol_kg)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.offshore$DIC_umol_kg
## W = 0.92737, p-value = 8.011e-13
DIC_of_0<-lmer(DIC_umol_kg~Year * Sub_region + 
               (1|Month) + (1|SiteID),
               data=Trends.offshore)
#summary(DIC_of_0)    
anova(DIC_of_0)
ranova(DIC_of_0)
step(DIC_of_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -1695.8 3413.7                         
## (1 | SiteID)          1   10 -1695.8 3411.7   0.00  1          1    
## (1 | Month)           0    9 -1757.9 3533.8 124.11  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value   Pr(>F)   
## Year:Sub_region          1  878.8  292.95     3 370.59  0.8509 0.466791   
## Year                     2  406.7  406.66     1 384.15  1.1825 0.277525   
## Sub_region               0 4526.5 1508.84     3 374.98  4.3971 0.004676 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## DIC_umol_kg ~ Sub_region + (1 | Month)
DIC_of<-lmer(DIC_umol_kg ~ Year + Sub_region + (1 | Month), 
               data =Trends.offshore)
  summary(DIC_of)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: DIC_umol_kg ~ Year + Sub_region + (1 | Month)
##    Data: Trends.offshore
## 
## REML criterion at convergence: 3400.6
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -5.8843 -0.4329  0.1397  0.6130  2.4102 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 243.8    15.61   
##  Residual             343.9    18.54   
## Number of obs: 390, groups:  Month, 12
## 
## Fixed effects:
##               Estimate Std. Error        df t value Pr(>|t|)   
## (Intercept)   792.3190  1154.5069  384.1392   0.686  0.49295   
## Year            0.6221     0.5721  384.1451   1.087  0.27753   
## Sub_regionUK   -2.9722     2.9870  373.5600  -0.995  0.32037   
## Sub_regionMK   -9.1133     2.9547  373.5576  -3.084  0.00219 **
## Sub_regionLK   -1.3305     2.8028  373.7602  -0.475  0.63528   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.007  0.006              
## Sub_reginMK -0.007  0.005  0.590       
## Sub_reginLK -0.020  0.019  0.624  0.632
  anova(DIC_of) 
  plot(DIC_of)

  qqnorm(resid(DIC_of))

  acf(resid(DIC_of), main="acf(resid(DIC offshore))")  

  Temp_of.emmc<-emmeans(DIC_of, ~Sub_region+Year)
    Temp_of.emmc<-multcomp::cld(Temp_of.emmc)
    #Temp_in.emmc<-as.data.frame(Temp_in.emmc[complete.cases(Temp_in.emmc),])
    Temp_of.emmc<-Temp_of.emmc[order(Temp_of.emmc$Sub_region),]
    Temp_of.emmc
#write.csv(Temp_of.emmc, "FLK_results/Model_11_LTpH_POST.csv")
# Create a new data frame for independent variables  
  Of_Newdata<-expand.grid(one=unique(Trends.offshore$Zone),
                                Sub_region=unique(Trends.offshore$Sub_region),
                          Year=seq((min(Trends.offshore$Year)-0), (max(Trends.offshore$Year)+1)))
  Of_DIC_Pred <- predict(DIC_of, newdata=Of_Newdata, re.form=NA, level=0, asList = FALSE)
  
  Of_DIC_Pred <-cbind(Of_Newdata, Of_DIC_Pred)
  Of_DIC_Pred$Date<-as.Date(as.character(Of_DIC_Pred$Year), format = "%Y")
  
# Model summary for labels
  slope<-round(summary(DIC_of)$coefficients["Year", "Estimate"], digits = 3)
  ys <- max(Trends.offshore$DIC_umol_kg, na.rm =T)
  plot_label <- sprintf("\"\" ~ DIC[Ar] == %0.3f", slope)
  plot_label2 <- expression("Year^-1")
  
# Plot raw data point and fitted model 
  Of_DIC_Modeled<-Long_plot2+ #facet_grid(~Zone)+
     scale_y_continuous(#limits = c(15,40),
                       #name=(expression("Aragonite saturation state" ~(DIC[Ar]))),
                      name=(expression(~DIC[Ar])),
                       limits = c(3, 4.5),
                       breaks = seq(0, 10, 0.5),  
                       expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.offshore, 
                               aes(y=DIC_umol_kg, x=Date, 
                                  #fill = Sub_region), 
                                  colour = Sub_region), 
                               alpha=0.5, size=0.5, shape=24)+
      geom_line(data=Of_DIC_Pred, aes(y = Of_DIC_Pred,
                                      x=Date, colour = Sub_region), linetype=1, size=1)+
      annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
               #label = expression("~DIC[Ar] == -0.015** ~Year ^-1"), 
               label =paste0(as.character(plot_label, plot_label2, sep = " ")),
               size=4)
  Of_DIC_Modeled

Oceanic

hist(Trends.ocean$DIC_umol_kg)

shapiro.test(Trends.ocean$DIC_umol_kg)# Normality NOT rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.ocean$DIC_umol_kg
## W = 0.98641, p-value = 0.1591
DIC_oc_0<-lmer(DIC_umol_kg ~ Year * Sub_region + 
               (1 | Month)+ (1|SiteID),
               data=Trends.ocean)

DIC_oc_1<-lmer(DIC_umol_kg ~ Year * Sub_region * Season++ (1|SiteID),
               data=Trends.ocean)
  #summary(DIC_oc_0)
  #summary(DIC_oc_1)    
  #anova(DIC_oc_1) 
  anova(DIC_oc_0)
  ranova(DIC_oc_0)
  step(DIC_oc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                     9 -579.29 1176.6                         
## (1 | SiteID)          1    8 -579.29 1174.6  0.000  1          1    
## (1 | Month)           0    7 -599.53 1213.1 40.494  1  1.972e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value    Pr(>F)    
## Year:Sub_region          1  166.40   83.20     2 129.53  0.5593 0.5730028    
## Sub_region               2  121.96   60.98     2 131.46  0.4125 0.6628785    
## Year                     0 1859.81 1859.81     1 144.81 12.6915 0.0004977 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## DIC_umol_kg ~ Year + (1 | Month)
DIC_oc<-lmer(DIC_umol_kg ~ Year + (1 | Month), data = Trends.ocean)
  summary(DIC_oc)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: DIC_umol_kg ~ Year + (1 | Month)
##    Data: Trends.ocean
## 
## REML criterion at convergence: 1171.9
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.4190 -0.4733  0.1114  0.6111  2.2162 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 125.5    11.20   
##  Residual             146.5    12.11   
## Number of obs: 147, groups:  Month, 12
## 
## Fixed effects:
##               Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept) -2168.1995  1182.8873   144.8121  -1.833 0.068860 .  
## Year            2.0884     0.5862   144.8109   3.563 0.000498 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##      (Intr)
## Year -1.000
  anova(DIC_oc)
  plot(DIC_oc)

  qqnorm(resid(DIC_oc))

  acf(resid(DIC_oc), main="acf(resid(DIC open))")

  Temp_oc.emmc<-emmeans(DIC_oc, ~Year)
    #Temp_oc.emmc<-multcomp::cld(Temp_oc.emmc)
    #Temp_oc.emmc<-as.data.frame(Temp_in.emmc[complete.cases(Temp_in.emmc),])
    #Temp_oc.emmc<-Temp_oc.emmc[order(Temp_oc.emmc$Sub_region),]
    #Temp_oc.emmc
# Create a new data frame for independent variables  
  Oc_Newdata<-expand.grid(one=unique(Trends.ocean$Zone),
                                Sub_region=unique(Trends.ocean$Sub_region),
                          Year=seq((min(Trends.ocean$Year)-0), (max(Trends.ocean$Year)+1)))
  Oc_DIC_Pred <- predict(DIC_oc, newdata=Oc_Newdata, re.form=NA, level=0, asList = FALSE)
  
  Oc_DIC_Pred <-cbind(Oc_Newdata, Oc_DIC_Pred)
  Oc_DIC_Pred$Date<-as.Date(as.character(Oc_DIC_Pred$Year), format = "%Y")
  
# Model summary for labels
  slope<-round(summary(DIC_oc)$coefficients["Year", "Estimate"], digits = 3)
  #xs <- as.Date(as.character("2018-11-20"))
  #ys <- max(Trends.inshore$DIC_umol_kg, na.rm =T)
  ys <- max(Trends.offshore$DIC_umol_kg, na.rm =T)
  plot_label <- sprintf("\"\" ~ DIC[Ar] == %0.3f", slope)
  plot_label2 <- expression("Year^-1")
  
# Plot raw data point and fitted model 
  
  Oc_DIC_Modeled<-Long_plot2+ #facet_grid(~Zone)+
     scale_y_continuous(#limits = c(15,40),
                       #name=(expression("Aragonite saturation state" ~(DIC[Ar]))),
                      name=(expression(~DIC[Ar])),
                       limits = c(3, 4.5),
                       breaks = seq(0, 10, 0.5),  
                       expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.ocean, 
                               aes(y=DIC_umol_kg, x=Date, 
                                   #fill = Sub_region), 
                                  colour = Sub_region), 
                               alpha=0.5, size=0.5, shape=25)+
      geom_line(data=Oc_DIC_Pred, aes(y = Oc_DIC_Pred,
                                      x=Date), linetype=1, size=1, colour = "black") +
    
      annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
               #label = expression("~DIC[Ar] == -0.015** ~Year ^-1"), 
               label =paste0(as.character(plot_label, plot_label2, sep = " ")),
               size=4)
  Oc_DIC_Modeled

Models summary

Complete models

# ANOVAs
    # Convert ANOVA results into dataframes allows for easier name manipulation
    av.DIC_in_0 <- data.frame (anova(DIC_in_0))
    av.DIC_mc_0 <- data.frame (anova(DIC_mc_0) )
    av.DIC_of_0 <- data.frame (anova(DIC_of_0))
    av.DIC_oc_0 <- data.frame (anova(DIC_oc_0))
    
    # Putting all into one dataframe/table
    anova_DIC_0 <- data.frame(cbind
                    (c("Year", "Sub_region", "Year:Sub_region", 
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region"), 
                                      rbind(av.DIC_in_0, av.DIC_mc_0,
                                            av.DIC_of_0, av.DIC_oc_0))) 
    colnames(anova_DIC_0) <- c("", "Sum Sq", "Mean Sq", "N Df" , "D Df",
                                     "F value", "Pr(>F)")
    row.names(anova_DIC_0) <- NULL
    
    # create HTML table using kableExtra
    anova_DIC_0 %>% kable("html", digits=2, 
        caption="Initial DIC models fixed factors: Year*Region") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "DIC inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "DIC mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "DIC offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "DIC ocean", 10, 12)  
Initial DIC models fixed factors: Year*Region
Sum Sq Mean Sq N Df D Df F value Pr(>F)
DIC inshore
Year 115.67 115.67 1 328.24 0.02 0.88
Sub_region 25873.54 8624.51 3 318.54 1.80 0.15
Year:Sub_region 25839.52 8613.17 3 318.54 1.80 0.15
DIC mid-channel
Year 2645.10 2645.10 1 305.07 1.31 0.25
Sub_region 9048.05 3016.02 3 293.56 1.50 0.21
Year:Sub_region 9047.72 3015.91 3 293.56 1.50 0.21
DIC offshore
Year 435.49 435.49 1 381.47 1.26 0.26
Sub_region 882.69 294.23 3 370.58 0.85 0.46
Year:Sub_region 878.84 292.95 3 370.58 0.85 0.47
DIC ocean
Year 1746.29 1746.29 1 140.60 11.74 0.00
Sub_region 166.54 83.27 2 129.54 0.56 0.57
Year:Sub_region 166.40 83.20 2 129.54 0.56 0.57
# R-ANOVAs    
    rav.DIC_in_0 <- data.frame (ranova(DIC_in_0))
    rav.DIC_mc_0 <- data.frame (ranova(DIC_mc_0) )
    rav.DIC_of_0 <- data.frame (ranova(DIC_of_0))
    rav.DIC_oc_0 <- data.frame (ranova(DIC_oc_0))
    
    # Putting all into one dataframe/table
    ranova_DIC_0 <- data.frame(cbind
                    (c("<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)"), 
                      rbind(rav.DIC_in_0, rav.DIC_mc_0,
                            rav.DIC_of_0, rav.DIC_oc_0))) 
    colnames(ranova_DIC_0) <- c("", "npar", "logLik", "AIC" , "LRT",
                                     "DF", "Pr(>Chi Sq)")
    row.names(ranova_DIC_0) <- NULL
    
    # create HTML table using kableExtra
    ranova_DIC_0 %>% kable("html", digits=2,
         caption="Initial DIC models random factors: Month+Station") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "DIC inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "DIC mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "DIC offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "DIC ocean", 10, 12)  
Initial DIC models random factors: Month+Station
npar logLik AIC LRT DF Pr(>Chi Sq)
DIC inshore
<none> 11 -1944.80 3911.60
(1 | Month) 10 -2065.72 4151.43 241.83 1 0.00
(1 | SiteID) 10 -1947.36 3914.71 5.11 1 0.02
DIC mid-channel
<none> 11 -1657.98 3337.96
(1 | Month) 10 -1723.77 3467.54 131.58 1 0.00
(1 | SiteID) 10 -1658.67 3337.35 1.39 1 0.24
DIC offshore
<none> 11 -1695.84 3413.68
(1 | Month) 10 -1757.89 3535.78 124.10 1 0.00
(1 | SiteID) 10 -1695.84 3411.68 0.00 1 1.00
DIC ocean
<none> 9 -579.29 1176.57
(1 | Month) 8 -599.53 1215.07 40.49 1 0.00
(1 | SiteID) 8 -579.29 1174.57 0.00 1 1.00
DIC_models_0<-list("Inshore" = DIC_in_0, 
                   "Mid channel" = DIC_mc_0, 
                   "Offshore" = DIC_of_0, 
                   "Ocean" = DIC_oc_0)
modelsummary(DIC_models_0, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'Initial DIC model outputs (all factors)',
             coef_map=factor_order)
Initial DIC model outputs (all factors)
Inshore Mid channel Offshore Ocean
Year −1.204 −1.704 0.411 2.458*
(4.270) (2.806) (1.149) (1.166)
Intercept 4485.249 5485.277 1218.372 −2916.483
(8616.533) (5661.336) (2318.160) (2352.383)
Upper Keys 2735.858 1995.060 −317.924
(10911.264) (7778.521) (2873.140)
Middle Keys −17050.458 −7159.241 −2728.834 −40.890
(10582.937) (6881.067) (2846.080) (2689.779)
Lower Keys 1545.619 5775.656 1062.283 2062.856
(10658.465) (6948.171) (2711.348) (2708.649)
Num.Obs. 344 318 390 147
R2 Marg. 0.062 0.035 0.043 0.126
R2 Cond. 0.624 0.487
AIC 3911.6 3338.0 3413.7 1176.6
BIC 3953.9 3379.3 3457.3 1203.5
ICC 0.6 0.5
RMSE 66.87 43.34 18.11 11.52
+ p
#modelsummary(DIC_models, estimate = "p.value")

Models with non-significant factors removed

DIC_models<-list("Inshore" = DIC_in, 
                   "Mid channel" = DIC_mc, 
                   "Offshore" = DIC_of, 
                   "Ocean" = DIC_oc)
modelsummary(DIC_models, stars = TRUE, 
            #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'Final DIC model outputs (dropped factors)',
             coef_map=factor_order)
Final DIC model outputs (dropped factors)
Inshore Mid channel Offshore Ocean
Year 0.683 −1.571 0.622 2.088***
(2.318) (1.548) (0.572) (0.586)
Intercept 675.945 5217.407+ 792.319 −2168.199+
(4678.187) (3124.726) (1154.507) (1182.887)
Upper Keys −16.463 −8.845 −2.972
(18.597) (8.252) (2.987)
Middle Keys −46.289* −21.745** −9.113**
(18.509) (7.279) (2.955)
Lower Keys −70.752*** −24.605*** −1.330
(18.478) (7.267) (2.803)
Num.Obs. 344 318 390 147
R2 Marg. 0.057 0.027 0.022 0.067
R2 Cond. 0.619 0.468 0.428 0.498
AIC 3925.6 3348.0 3414.6 1179.9
BIC 3956.3 3374.4 3442.4 1191.9
ICC 0.6 0.5 0.4 0.5
RMSE 67.43 44.23 18.17 11.61
+ p
modelsummary(DIC_models, output = "FLK_results/Figures/Fig_2/Trend_DIC.docx")
#modelsummary(DIC_models, estimate = "p.value")
Trends_DIC<-ggarrange(In_DIC_Modeled+ theme(
                                          #axis.text.x=element_blank(),
                                          legend.position = "none"),
                  Mc_DIC_Modeled+ theme(legend.position = "none",
                                           #axis.text.x=element_blank(),
                                           axis.title.y=element_blank()),
                                
                  Of_DIC_Modeled + theme(legend.position = "none",
                                           #axis.text.x=element_blank(),
                                           axis.title.y=element_blank()),
                                
                  Oc_DIC_Modeled + theme(legend.position = "none",
                                           #axis.text.x=element_blank(),
                                           axis.title.y=element_blank()),
                                           
          labels = c("C"),
          ncol = 4, nrow = 1, widths =c(1.1, 1, 1, 1))
Trends_DIC

Omega-All

## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.data$Aragonite_Sat_W
## W = 0.97129, p-value = 1.141e-14

## Model with all data
Omega_all_o<-lmer(Aragonite_Sat_W~Year * Zone * Sub_region + (1|Month)+           
                                    (1|SiteID), data=Trends.data)
  step(Omega_all_o)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC     LRT Df Pr(>Chisq)    
## <none>                    33 -275.96 617.91                          
## (1 | SiteID)          1   32 -276.49 616.97   1.059  1     0.3035    
## (1 | Month)           0   31 -432.83 927.66 312.693  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                      Eliminated Sum Sq Mean Sq NumDF  DenDF F value    Pr(>F)
## Year:Zone:Sub_region          1 0.1748 0.02185     8 1156.1  0.2736   0.97455
## Year:Sub_region               2 0.0829 0.02764     3 1164.2  0.3478   0.79074
## Year:Zone                     0 0.8539 0.28463     3 1167.1  3.5882   0.01334
## Zone:Sub_region               0 5.8363 0.72953     8 1167.1  9.1967 2.436e-12
##                         
## Year:Zone:Sub_region    
## Year:Sub_region         
## Year:Zone            *  
## Zone:Sub_region      ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## Aragonite_Sat_W ~ Year + Zone + Sub_region + (1 | Month) + Year:Zone + Zone:Sub_region
Omega_all_1<-lmer(Aragonite_Sat_W ~ Year + Zone + Sub_region + (1 | Month) +
                      Year:Zone + Zone:Sub_region, data=Trends.data)

Omega_all_3<-lmer(Aragonite_Sat_W ~ Year + Zone + (1 | Month) + (1|Sub_region)+
                       Year:Zone, data=Trends.data)
    

anova(Omega_all_1, Omega_all_3)
    summary(Omega_all_1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: 
## Aragonite_Sat_W ~ Year + Zone + Sub_region + (1 | Month) + Year:Zone +  
##     Zone:Sub_region
##    Data: Trends.data
## 
## REML criterion at convergence: 490
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.7230 -0.5939  0.0796  0.5686  5.2083 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 0.02962  0.1721  
##  Residual             0.07933  0.2816  
## Number of obs: 1197, groups:  Month, 12
## 
## Fixed effects:
##                                Estimate Std. Error         df t value Pr(>|t|)
## (Intercept)                  -2.821e+01  1.601e+01  1.178e+03  -1.762  0.07836
## Year                          1.579e-02  7.935e-03  1.178e+03   1.990  0.04680
## ZoneMid channel               1.954e+01  2.116e+01  1.167e+03   0.923  0.35598
## ZoneOffshore                  5.313e+01  2.015e+01  1.167e+03   2.636  0.00849
## ZoneOceanic                   7.107e+01  2.661e+01  1.167e+03   2.670  0.00768
## Sub_regionUK                  2.157e-01  4.573e-02  1.167e+03   4.715 2.70e-06
## Sub_regionMK                  9.529e-02  4.516e-02  1.167e+03   2.110  0.03506
## Sub_regionLK                 -2.871e-01  4.489e-02  1.167e+03  -6.394 2.33e-10
## Year:ZoneMid channel         -9.644e-03  1.049e-02  1.167e+03  -0.920  0.35799
## Year:ZoneOffshore            -2.627e-02  9.986e-03  1.167e+03  -2.631  0.00863
## Year:ZoneOceanic             -3.501e-02  1.319e-02  1.167e+03  -2.655  0.00805
## ZoneMid channel:Sub_regionUK -7.882e-02  6.864e-02  1.167e+03  -1.148  0.25107
## ZoneOffshore:Sub_regionUK    -1.749e-01  6.441e-02  1.167e+03  -2.716  0.00671
## ZoneOceanic:Sub_regionUK     -4.250e-01  7.820e-02  1.167e+03  -5.434 6.69e-08
## ZoneMid channel:Sub_regionMK -3.654e-02  6.384e-02  1.167e+03  -0.572  0.56719
## ZoneOffshore:Sub_regionMK    -7.284e-02  6.363e-02  1.167e+03  -1.145  0.25259
## ZoneOceanic:Sub_regionMK     -3.441e-01  6.560e-02  1.167e+03  -5.245 1.86e-07
## ZoneMid channel:Sub_regionLK  1.859e-01  6.351e-02  1.167e+03   2.928  0.00348
## ZoneOffshore:Sub_regionLK     2.458e-01  6.180e-02  1.167e+03   3.977 7.41e-05
##                                 
## (Intercept)                  .  
## Year                         *  
## ZoneMid channel                 
## ZoneOffshore                 ** 
## ZoneOceanic                  ** 
## Sub_regionUK                 ***
## Sub_regionMK                 *  
## Sub_regionLK                 ***
## Year:ZoneMid channel            
## Year:ZoneOffshore            ** 
## Year:ZoneOceanic             ** 
## ZoneMid channel:Sub_regionUK    
## ZoneOffshore:Sub_regionUK    ** 
## ZoneOceanic:Sub_regionUK     ***
## ZoneMid channel:Sub_regionMK    
## ZoneOffshore:Sub_regionMK       
## ZoneOceanic:Sub_regionMK     ***
## ZoneMid channel:Sub_regionLK ** 
## ZoneOffshore:Sub_regionLK    ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## fit warnings:
## fixed-effect model matrix is rank deficient so dropping 1 column / coefficient
    anova(Omega_all_1)
    ranova(Omega_all_1)
# Obtain slopes
    #ranef(Omega_all_1)
    #fixef(Omega_all_1)
    #coef(Omega_all_1)$Month
    #coef(Omega_all_1)$Zone

  m.lst <- lstrends(Omega_all_1, "Zone", var="Year")
  m.lst
##  Zone        Year.trend      SE   df  lower.CL upper.CL
##  Inshore        0.01579 0.00795 1178  0.000197  0.03138
##  Mid channel    0.00615 0.00819 1178 -0.009914  0.02221
##  Offshore      -0.01048 0.00752 1178 -0.025226  0.00427
##  Oceanic       -0.01922 0.01141 1174 -0.041605  0.00316
## 
## Results are averaged over the levels of: Sub_region 
## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95
  pairs(m.lst)
##  contrast               estimate      SE   df t.ratio p.value
##  Inshore - Mid channel   0.00964 0.01049 1167   0.920  0.7944
##  Inshore - Offshore      0.02627 0.00999 1167   2.631  0.0428
##  Inshore - Oceanic       0.03501 0.01319 1167   2.655  0.0401
##  Mid channel - Offshore  0.01663 0.01018 1167   1.633  0.3602
##  Mid channel - Oceanic   0.02537 0.01333 1167   1.903  0.2275
##  Offshore - Oceanic      0.00874 0.01294 1167   0.675  0.9064
## 
## Results are averaged over the levels of: Sub_region 
## Degrees-of-freedom method: kenward-roger 
## P value adjustment: tukey method for comparing a family of 4 estimates

Inshore

# Inshore Omega
  hist(Trends.inshore$Aragonite_Sat_W)

  shapiro.test(Trends.inshore$Aragonite_Sat_W) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.inshore$Aragonite_Sat_W
## W = 0.98784, p-value = 0.005584
  Omega_in_0<-lmer(Aragonite_Sat_W~Year * Sub_region + (1|Month)+
                                    #(1|Zone)+             
                                    (1|SiteID), data=Trends.inshore)
  
  Omega_in_1<-lmer(Aragonite_Sat_W~Year * Sub_region * Season +
                                    #(1|Zone)+             
                                    (1|SiteID), data=Trends.inshore)
  
  #summary(Omega_in_0)
  #summary(Omega_in_1)    
  #anova(Omega_in_0, Omega_in_1)
  #step(Omega_in_1)
  
  anova(Omega_in_0)
  ranova(Omega_in_0)
  step(Omega_in_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -146.35 314.69                         
## (1 | Month)           0   10 -264.88 549.77 237.08  1    < 2e-16 ***
## (1 | SiteID)          0   10 -147.81 315.62   2.93  1    0.08695 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value   Pr(>F)   
## Year:Sub_region          1 0.0379 0.01263     3 318.47  0.1166 0.950349   
## Year                     2 0.0016 0.00164     1 331.77  0.0153 0.901788   
## Sub_region               0 5.1900 1.73001     3   6.95 16.1496 0.001627 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## Aragonite_Sat_W ~ Sub_region + (1 | Month) + (1 | SiteID)
  Omega_in<-lmer(Aragonite_Sat_W ~ Sub_region + (1 | Month),
                 data=Trends.inshore)
  anova(Omega_in)
  summary(Omega_in)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Aragonite_Sat_W ~ Sub_region + (1 | Month)
##    Data: Trends.inshore
## 
## REML criterion at convergence: 271.4
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.8965 -0.5776  0.0404  0.5861  4.0803 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 0.1377   0.3711  
##  Residual             0.1100   0.3317  
## Number of obs: 344, groups:  Month, 12
## 
## Fixed effects:
##               Estimate Std. Error        df t value Pr(>|t|)    
## (Intercept)    3.65753    0.11476  13.72116  31.872  2.9e-14 ***
## Sub_regionUK   0.20061    0.05388 329.15463   3.723 0.000231 ***
## Sub_regionMK   0.09233    0.05325 329.15902   1.734 0.083875 .  
## Sub_regionLK  -0.28142    0.05297 329.19192  -5.313  2.0e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Sb_rUK Sb_rMK
## Sub_reginUK -0.267              
## Sub_reginMK -0.271  0.573       
## Sub_reginLK -0.272  0.574  0.586
  plot(Omega_in)

  qqnorm(resid(Omega_in))

  acf(resid(Omega_in), main="acf(resid(Omega Inshore))")

  Arg_in.emmc<-emmeans(Omega_in, ~Sub_region)
    Arg_in.emmc<-multcomp::cld(Arg_in.emmc)
    #Arg_in.emmc<-as.data.frame(Arg_in.emmc[complete.cases(Arg_in.emmc),])
    Arg_in.emmc<-Arg_in.emmc[order(Arg_in.emmc$Sub_region),]
    Arg_in.emmc
  #write.csv(Arg_in.emmc, "FLK_results/Model_9_LTpH_POST.csv")
    round(Arg_in.emmc$emmean, digits = 2)
## [1] 3.66 3.86 3.75 3.38
  #anova(Omega_in)
  #ranova(Omega_in)
# Create a new data frame for independent variables  
  In_Newdata<-expand.grid(Zone=unique(Trends.inshore$Zone),
                          Sub_region=unique(Trends.inshore$Sub_region),
                          Year=seq((min(Trends.inshore$Year)-0), (max(Trends.inshore$Year)+1)))
  In_Omega_Pred <- predict(Omega_in, newdata=In_Newdata, re.form=NA, level=0, asList = FALSE)
  
  In_Omega_Pred <-cbind(In_Newdata, In_Omega_Pred)
  In_Omega_Pred$Date<-as.Date(as.character(In_Omega_Pred$Year), format = "%Y")
  
  
# Plot raw data point and fitted model 
  
  In_Omega_Modeled<-Long_plot2+ #facet_grid(~Zone)+
     scale_y_continuous(#limits = c(0,6),
                       #name=(expression("Aragonite saturation state" ~(Omega[Ar]))),
                       name=(expression(~Omega[Ar])),
                       limits = c(2.3, 5.2),
                       breaks = seq(0, 10, 0.5),  
                       expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.inshore, 
                               aes(y=Aragonite_Sat_W, x=Date, 
                                  #fill = Sub_region), 
                                  colour = Sub_region), 
                               alpha=0.5, size=0.5, shape=21)+
      geom_line(data=In_Omega_Pred, aes(y = In_Omega_Pred,
                                      x=Date, colour = Sub_region), linetype=2, size=1) 
  In_Omega_Modeled

Mid channel

hist(Trends.midchanel$Aragonite_Sat_W)

shapiro.test(Trends.midchanel$Aragonite_Sat_W)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.midchanel$Aragonite_Sat_W
## W = 0.97844, p-value = 0.0001033
Omega_mc_0<-lmer(Aragonite_Sat_W~Year * Sub_region + (1|Month) + 
                                  #(1|Zone)+             
                                  (1|SiteID), data=Trends.midchanel)

# Omega_mc_1<-lmer(Aragonite_Sat_W~Year * Sub_region * Season +
#                                     #(1|Zone)+             
#                                     (1|SiteID), data=Trends.midchanel)

#summary(Omega_mc_0)    
#summary(Omega_mc_1)  

anova(Omega_mc_0)
#anova(Omega_mc_1)
#anova(Omega_mc_0, Omega_mc_1)
ranova(Omega_mc_0)
step(Omega_mc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik     AIC     LRT Df Pr(>Chisq)    
## <none>                    11 -15.198  52.395                          
## (1 | SiteID)          1   10 -16.127  52.255   1.859  1     0.1727    
## (1 | Month)           0    9 -79.135 176.269 126.015  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value    Pr(>F)    
## Year:Sub_region          1 0.05438 0.01813     3 299.17  0.3525    0.7873    
## Year                     2 0.02606 0.02606     1 312.46  0.5102    0.4756    
## Sub_region               0 2.38338 0.79446     3 303.20 15.5664 1.923e-09 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## Aragonite_Sat_W ~ Sub_region + (1 | Month)
Omega_mc<-lmer(Aragonite_Sat_W ~ Year + Sub_region + (1 | Month),
               data = Trends.midchanel)
  summary(Omega_mc) 
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Aragonite_Sat_W ~ Year + Sub_region + (1 | Month)
##    Data: Trends.midchanel
## 
## REML criterion at convergence: 13.9
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.4729 -0.5930  0.0842  0.6008  3.5456 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 0.03657  0.1912  
##  Residual             0.05109  0.2260  
## Number of obs: 318, groups:  Month, 12
## 
## Fixed effects:
##                Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept)   -7.359615  15.532368 312.454982  -0.474 0.635956    
## Year           0.005498   0.007697 312.458538   0.714 0.475605    
## Sub_regionUK   0.139603   0.041133 302.227159   3.394 0.000781 ***
## Sub_regionMK   0.058395   0.036283 302.155015   1.609 0.108564    
## Sub_regionLK  -0.100180   0.036221 302.296169  -2.766 0.006028 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.019  0.018              
## Sub_reginMK -0.004  0.003  0.528       
## Sub_reginLK -0.025  0.024  0.531  0.602
  anova(Omega_mc) 
  plot(Omega_mc)

  qqnorm(resid(Omega_mc))

  acf(resid(Omega_mc), main="acf(resid(Omega mid Channel))")  

  Arg_md.emmc<-emmeans(Omega_mc, ~Sub_region+Year)
    Arg_md.emmc<-multcomp::cld(Arg_md.emmc)
    #Arg_in.emmc<-as.data.frame(Arg_in.emmc[complete.cases(Arg_in.emmc),])
    Arg_md.emmc<-Arg_md.emmc[order(Arg_md.emmc$Sub_region),]
    Arg_md.emmc
  #write.csv(Arg_md.emmc, "FLK_results/Model_10_LTpH_POST.csv")
# Create a new data frame for independent variables  
  Mc_Newdata<-expand.grid(Zone=unique(Trends.midchanel$Zone),
                                Sub_region=unique(Trends.midchanel$Sub_region),
                          Year=seq((min(Trends.midchanel$Year)-0), (max(Trends.midchanel$Year)+1)))
  Mc_Omega_Pred <- predict(Omega_mc, newdata=Mc_Newdata, re.form=NA, level=0, asList = FALSE)
  
  Mc_Omega_Pred <-cbind(Mc_Newdata, Mc_Omega_Pred)
  Mc_Omega_Pred$Date<-as.Date(as.character(Mc_Omega_Pred$Year), format = "%Y")
  
  
# Model summary for labels
  slope<-round(
      summary(Omega_mc)$coefficients["Year", "Estimate"], digits = 3)
  ys <- max(Trends.midchanel$Aragonite_Sat_W, na.rm =T)+ 0.3

# Plot raw data point and fitted model 
  plot_label <- sprintf("\"\" ~ Omega[Ar] == %0.3f", slope)
  plot_label2 <- expression("Year^-1")
  
  Mc_Omega_Modeled<-Long_plot2+ #facet_grid(~Zone)+
     scale_y_continuous(#limits = c(15,40),
                       #name=(expression("Aragonite saturation state" ~(Omega[Ar]))),
                       name=(expression(~Omega[Ar])),
                       limits = c(2.3, 5.2),
                       breaks = seq(0, 10, 0.5),  
                       expand = c(0.02, 0.02)) +
    
      geom_jitter(data=Trends.midchanel, 
                               aes(y=Aragonite_Sat_W, x=Date, 
                                  #fill = Sub_region), 
                                  colour = Sub_region), 
                               alpha=0.5, size=0.5, shape=23)+
      geom_line(data=Mc_Omega_Pred, aes(y = Mc_Omega_Pred,
                                      x=Date, colour = Sub_region), linetype=1, size=1)+
      # geom_text(data = slope, aes(x = xs, y = ys,
      #                       label = (paste("~Omega[Ar]", "=", 
      #                                     slope, "Year ^-1"))), size=10)
      annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
               #label = expression("~Omega[Ar] == -0.015** ~Year ^-1"), 
               label =paste0(as.character(plot_label, plot_label2, sep = " ")),
               size=4)
  Mc_Omega_Modeled

Offshore

hist(Trends.offshore$Aragonite_Sat_W)

shapiro.test(Trends.offshore$Aragonite_Sat_W)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.offshore$Aragonite_Sat_W
## W = 0.99379, p-value = 0.1136
Omega_of_0<-lmer(Aragonite_Sat_W~Year * Sub_region + 
               (1|Month) + (1|SiteID),
               data=Trends.offshore)
#summary(Omega_of_0)    
anova(Omega_of_0)
ranova(Omega_of_0)
step(Omega_of_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar logLik     AIC     LRT Df Pr(>Chisq)    
## <none>                    11 208.49 -394.97                          
## (1 | SiteID)          1   10 207.77 -395.53   1.438  1     0.2305    
## (1 | Month)           0    9 112.36 -206.72 190.817  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq  Mean Sq NumDF  DenDF F value    Pr(>F)    
## Year:Sub_region          1 0.06605 0.022018     3 368.71  1.3883    0.2460    
## Year                     2 0.02010 0.020105     1 382.74  1.2636    0.2617    
## Sub_region               0 0.46970 0.156565     3 372.88  9.8508 2.883e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## Aragonite_Sat_W ~ Sub_region + (1 | Month)
Omega_of<-lmer(Aragonite_Sat_W ~ Year + Sub_region + (1 | Month), 
               data =Trends.offshore)
  summary(Omega_of)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Aragonite_Sat_W ~ Year + Sub_region + (1 | Month)
##    Data: Trends.offshore
## 
## REML criterion at convergence: -434.9
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.9928 -0.5880  0.0290  0.6318  3.7875 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 0.01749  0.1322  
##  Residual             0.01591  0.1261  
## Number of obs: 388, groups:  Month, 12
## 
## Fixed effects:
##                Estimate Std. Error         df t value Pr(>|t|)   
## (Intercept)   12.654489   7.902638 382.739787   1.601  0.11014   
## Year          -0.004402   0.003916 382.735971  -1.124  0.26167   
## Sub_regionUK   0.030178   0.020318 371.700710   1.485  0.13831   
## Sub_regionMK   0.023864   0.020098 371.699196   1.187  0.23584   
## Sub_regionLK  -0.051178   0.019121 371.848012  -2.677  0.00777 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.008  0.006              
## Sub_reginMK -0.007  0.006  0.590       
## Sub_reginLK -0.021  0.019  0.622  0.630
  anova(Omega_of) 
  plot(Omega_of)

  qqnorm(resid(Omega_of))

  acf(resid(Omega_of), main="acf(resid(Omega offshore))")  

  Arg_of.emmc<-emmeans(Omega_of, ~Sub_region+Year)
    Arg_of.emmc<-multcomp::cld(Arg_of.emmc)
    #Arg_in.emmc<-as.data.frame(Arg_in.emmc[complete.cases(Arg_in.emmc),])
    Arg_of.emmc<-Arg_of.emmc[order(Arg_of.emmc$Sub_region),]
    Arg_of.emmc
#write.csv(Arg_of.emmc, "FLK_results/Model_11_LTpH_POST.csv")
# Create a new data frame for independent variables  
  Of_Newdata<-expand.grid(one=unique(Trends.offshore$Zone),
                                Sub_region=unique(Trends.offshore$Sub_region),
                          Year=seq((min(Trends.offshore$Year)-0), (max(Trends.offshore$Year)+1)))
  Of_Omega_Pred <- predict(Omega_of, newdata=Of_Newdata, re.form=NA, level=0, asList = FALSE)
  
  Of_Omega_Pred <-cbind(Of_Newdata, Of_Omega_Pred)
  Of_Omega_Pred$Date<-as.Date(as.character(Of_Omega_Pred$Year), format = "%Y")
  
# Model summary for labels
  slope<-round(summary(Omega_of)$coefficients["Year", "Estimate"], digits = 3)
  ys <- max(Trends.offshore$Aragonite_Sat_W, na.rm =T)
  plot_label <- sprintf("\"\" ~ Omega[Ar] == %0.3f", slope)
  plot_label2 <- expression("Year^-1")
  
# Plot raw data point and fitted model 
  Of_Omega_Modeled<-Long_plot2+ #facet_grid(~Zone)+
     scale_y_continuous(#limits = c(15,40),
                       #name=(expression("Aragonite saturation state" ~(Omega[Ar]))),
                      name=(expression(~Omega[Ar])),
                       limits = c(3, 4.5),
                       breaks = seq(0, 10, 0.5),  
                       expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.offshore, 
                               aes(y=Aragonite_Sat_W, x=Date, 
                                  #fill = Sub_region), 
                                  colour = Sub_region), 
                               alpha=0.5, size=0.5, shape=24)+
      geom_line(data=Of_Omega_Pred, aes(y = Of_Omega_Pred,
                                      x=Date, colour = Sub_region), linetype=1, size=1)+
      annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
               #label = expression("~Omega[Ar] == -0.015** ~Year ^-1"), 
               label =paste0(as.character(plot_label, plot_label2, sep = " ")),
               size=4)
  Of_Omega_Modeled

Oceanic

hist(Trends.ocean$Aragonite_Sat_W)

shapiro.test(Trends.ocean$Aragonite_Sat_W)# Normality NOT rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.ocean$Aragonite_Sat_W
## W = 0.99088, p-value = 0.4623
Omega_oc_0<-lmer(Aragonite_Sat_W ~ Year * Sub_region + 
               (1 | Month)+ (1|SiteID),
               data=Trends.ocean)

Omega_oc_1<-lmer(Aragonite_Sat_W ~ Year * Sub_region * Season++ (1|SiteID),
               data=Trends.ocean)
  #summary(Omega_oc_0)
  #summary(Omega_oc_1)    
  #anova(Omega_oc_1) 
  anova(Omega_oc_0)
  ranova(Omega_oc_0)
  step(Omega_oc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar logLik      AIC    LRT Df Pr(>Chisq)    
## <none>                     9 93.333 -168.665                         
## (1 | SiteID)          1    8 93.333 -170.665   0.00  1          1    
## (1 | Month)           0    7 32.748  -51.496 121.17  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated   Sum Sq   Mean Sq NumDF  DenDF F value  Pr(>F)  
## Year:Sub_region          1 0.003904 0.0019522     2 129.73  0.2008 0.81833  
## Year                     2 0.014173 0.0141725     1 136.94  1.4752 0.22661  
## Sub_region               0 0.060793 0.0303965     2 132.85  3.1721 0.04511 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## Aragonite_Sat_W ~ Sub_region + (1 | Month)
Omega_oc<-lmer(Aragonite_Sat_W ~ Year + (1 | Month), data = Trends.ocean)
  summary(Omega_oc)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Aragonite_Sat_W ~ Year + (1 | Month)
##    Data: Trends.ocean
## 
## REML criterion at convergence: -207.1
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.2014 -0.6785 -0.0475  0.6953  2.8765 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 0.030147 0.17363 
##  Residual             0.009914 0.09957 
## Number of obs: 147, groups:  Month, 12
## 
## Fixed effects:
##               Estimate Std. Error         df t value Pr(>|t|)
## (Intercept)  15.844366   9.970239 139.100423   1.589    0.114
## Year         -0.005966   0.004941 139.093214  -1.207    0.229
## 
## Correlation of Fixed Effects:
##      (Intr)
## Year -1.000
  anova(Omega_oc)
  plot(Omega_oc)

  qqnorm(resid(Omega_oc))

  acf(resid(Omega_oc), main="acf(resid(Omega open))")

  Arg_oc.emmc<-emmeans(Omega_oc, ~Year)
    #Arg_oc.emmc<-multcomp::cld(Arg_oc.emmc)
    #Arg_oc.emmc<-as.data.frame(Arg_in.emmc[complete.cases(Arg_in.emmc),])
    #Arg_oc.emmc<-Arg_oc.emmc[order(Arg_oc.emmc$Sub_region),]
    #Arg_oc.emmc
# Create a new data frame for independent variables  
  Oc_Newdata<-expand.grid(one=unique(Trends.ocean$Zone),
                                Sub_region=unique(Trends.ocean$Sub_region),
                          Year=seq((min(Trends.ocean$Year)-0), (max(Trends.ocean$Year)+1)))
  Oc_Omega_Pred <- predict(Omega_oc, newdata=Oc_Newdata, re.form=NA, level=0, asList = FALSE)
  
  Oc_Omega_Pred <-cbind(Oc_Newdata, Oc_Omega_Pred)
  Oc_Omega_Pred$Date<-as.Date(as.character(Oc_Omega_Pred$Year), format = "%Y")
  
# Model summary for labels
  slope<-round(summary(Omega_oc)$coefficients["Year", "Estimate"], digits = 3)
  #xs <- as.Date(as.character("2018-11-20"))
  #ys <- max(Trends.inshore$Aragonite_Sat_W, na.rm =T)
  ys <- max(Trends.offshore$Aragonite_Sat_W, na.rm =T)
  plot_label <- sprintf("\"\" ~ Omega[Ar] == %0.3f", slope)
  plot_label2 <- expression("Year^-1")
  
# Plot raw data point and fitted model 
  
  Oc_Omega_Modeled<-Long_plot2+ #facet_grid(~Zone)+
     scale_y_continuous(#limits = c(15,40),
                       #name=(expression("Aragonite saturation state" ~(Omega[Ar]))),
                      name=(expression(~Omega[Ar])),
                       limits = c(3, 4.5),
                       breaks = seq(0, 10, 0.5),  
                       expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.ocean, 
                               aes(y=Aragonite_Sat_W, x=Date, 
                                   #fill = Sub_region), 
                                  colour = Sub_region), 
                               alpha=0.5, size=0.5, shape=25)+
      geom_line(data=Oc_Omega_Pred, aes(y = Oc_Omega_Pred,
                                      x=Date), linetype=1, size=1, colour = "black") +
    
      annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
               #label = expression("~Omega[Ar] == -0.015** ~Year ^-1"), 
               label =paste0(as.character(plot_label, plot_label2, sep = " ")),
               size=4)
  Oc_Omega_Modeled

Models summary

Complete models

# ANOVAs
    # Convert ANOVA results into dataframes allows for easier name manipulation
    av.Omega_in_0 <- data.frame (anova(Omega_in_0))
    av.Omega_mc_0 <- data.frame (anova(Omega_mc_0) )
    av.Omega_of_0 <- data.frame (anova(Omega_of_0))
    av.Omega_oc_0 <- data.frame (anova(Omega_oc_0))
    
    # Putting all into one dataframe/table
    anova_Omega_0 <- data.frame(cbind
                    (c("Year", "Sub_region", "Year:Sub_region", 
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region"), 
                                      rbind(av.Omega_in_0, av.Omega_mc_0,
                                            av.Omega_of_0, av.Omega_oc_0))) 
    colnames(anova_Omega_0) <- c("", "Sum Sq", "Mean Sq", "N Df" , "D Df",
                                     "F value", "Pr(>F)")
    row.names(anova_Omega_0) <- NULL
    
    # create HTML table using kableExtra
    anova_Omega_0 %>% kable("html", digits=2, 
        caption="Initial omega models fixed factors: Year*Region") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Omega inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "Omega mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "Omega offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "Omega ocean", 10, 12)  
Initial omega models fixed factors: Year*Region
Sum Sq Mean Sq N Df D Df F value Pr(>F)
Omega inshore
Year 0.00 0.00 1 328.73 0.00 0.95
Sub_region 0.04 0.01 3 318.47 0.12 0.95
Year:Sub_region 0.04 0.01 3 318.47 0.12 0.95
Omega mid-channel
Year 0.01 0.01 1 304.60 0.29 0.59
Sub_region 0.06 0.02 3 293.59 0.37 0.78
Year:Sub_region 0.06 0.02 3 293.59 0.37 0.78
Omega offshore
Year 0.03 0.03 1 371.83 1.77 0.18
Sub_region 0.07 0.02 3 360.94 1.41 0.24
Year:Sub_region 0.07 0.02 3 360.94 1.40 0.24
Omega ocean
Year 0.01 0.01 1 134.71 1.40 0.24
Sub_region 0.00 0.00 2 129.71 0.20 0.82
Year:Sub_region 0.00 0.00 2 129.71 0.20 0.82
# R-ANOVAs    
    rav.Omega_in_0 <- data.frame (ranova(Omega_in_0))
    rav.Omega_mc_0 <- data.frame (ranova(Omega_mc_0) )
    rav.Omega_of_0 <- data.frame (ranova(Omega_of_0))
    rav.Omega_oc_0 <- data.frame (ranova(Omega_oc_0))
    
    # Putting all into one dataframe/table
    ranova_Omega_0 <- data.frame(cbind
                    (c("<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)"), 
                      rbind(rav.Omega_in_0, rav.Omega_mc_0,
                            rav.Omega_of_0, rav.Omega_oc_0))) 
    colnames(ranova_Omega_0) <- c("", "npar", "logLik", "AIC" , "LRT",
                                     "DF", "Pr(>Chi Sq)")
    row.names(ranova_Omega_0) <- NULL
    
    # create HTML table using kableExtra
    ranova_Omega_0 %>% kable("html", digits=2,
         caption="Initial omega models random factors: Month+Station") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Omega inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "Omega mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "Omega offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "Omega ocean", 10, 12)  
Initial omega models random factors: Month+Station
npar logLik AIC LRT DF Pr(>Chi Sq)
Omega inshore
<none> 11 -146.35 314.69
(1 | Month) 10 -264.88 549.77 237.08 1 0.00
(1 | SiteID) 10 -147.81 315.62 2.93 1 0.09
Omega mid-channel
<none> 11 -15.20 52.40
(1 | Month) 10 -79.03 178.07 127.67 1 0.00
(1 | SiteID) 10 -16.13 52.25 1.86 1 0.17
Omega offshore
<none> 11 208.48 -394.97
(1 | Month) 10 112.36 -204.72 192.25 1 0.00
(1 | SiteID) 10 207.77 -395.53 1.44 1 0.23
Omega ocean
<none> 9 93.33 -168.67
(1 | Month) 8 32.75 -49.50 121.17 1 0.00
(1 | SiteID) 8 93.33 -170.67 0.00 1 1.00
Omega_models_0<-list("Inshore" = Omega_in_0, 
                   "Mid channel" = Omega_mc_0, 
                   "Offshore" = Omega_of_0, 
                   "Ocean" = Omega_oc_0)
modelsummary(Omega_models_0, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'Initial Omega model outputs (all factors)',
             coef_map=factor_order)
Initial Omega model outputs (all factors)
Inshore Mid channel Offshore Ocean
Year −0.007 −0.001 −0.008 −0.007
(0.020) (0.014) (0.008) (0.010)
Intercept 18.461 5.878 20.923 18.800
(40.951) (28.305) (15.637) (19.179)
Upper Keys −19.565 4.078 −12.566
(51.874) (38.927) (19.350)
Middle Keys −29.358 −18.516 8.870 1.129
(50.315) (34.434) (19.165) (21.769)
Lower Keys −15.957 −27.793 −22.561 −9.356
(50.674) (34.770) (18.267) (21.903)
Num.Obs. 344 318 388 147
R2 Marg. 0.121 0.081 0.042 0.059
R2 Cond. 0.620 0.477 0.554
AIC 314.7 52.4 −395.0 −168.7
BIC 356.9 93.8 −351.4 −141.8
ICC 0.6 0.4 0.5
RMSE 0.32 0.22 0.12 0.09
+ p
#modelsummary(Omega_models, estimate = "p.value")

Models with non-significant factors removed

Omega_models<-list("Inshore" = Omega_in, 
                   "Mid channel" = Omega_mc, 
                   "Offshore" = Omega_of, 
                   "Ocean" = Omega_oc)
modelsummary(Omega_models, stars = TRUE, 
            #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'Final Omega model outputs (dropped factors)',
             coef_map=factor_order)
Final Omega model outputs (dropped factors)
Inshore Mid channel Offshore Ocean
Year 0.005 −0.004 −0.006
(0.008) (0.004) (0.005)
Intercept 3.658*** −7.360 12.654 15.844
(0.115) (15.532) (7.903) (9.970)
Upper Keys 0.201*** 0.140*** 0.030
(0.054) (0.041) (0.020)
Middle Keys 0.092+ 0.058 0.024
(0.053) (0.036) (0.020)
Lower Keys −0.281*** −0.100** −0.051**
(0.053) (0.036) (0.019)
Num.Obs. 344 318 388 147
R2 Marg. 0.123 0.080 0.038 0.004
R2 Cond. 0.611 0.464 0.542 0.754
AIC 283.4 27.9 −420.9 −199.1
BIC 306.4 54.2 −393.2 −187.2
ICC 0.6 0.4 0.5 0.8
RMSE 0.32 0.22 0.12 0.10
+ p
modelsummary(Omega_models, output = "FLK_results/Figures/Fig_2/Trend_Omega.docx")
#modelsummary(Omega_models, estimate = "p.value")
Trends_Omega<-ggarrange(In_Omega_Modeled+ theme(
                                          #axis.text.x=element_blank(),
                                          legend.position = "none"),
                  Mc_Omega_Modeled+ theme(legend.position = "none",
                                           #axis.text.x=element_blank(),
                                           axis.title.y=element_blank()),
                                
                  Of_Omega_Modeled + theme(legend.position = "none",
                                           #axis.text.x=element_blank(),
                                           axis.title.y=element_blank()),
                                
                  Oc_Omega_Modeled + theme(legend.position = "none",
                                           #axis.text.x=element_blank(),
                                           axis.title.y=element_blank()),
                                           
          labels = c("C"),
          ncol = 4, nrow = 1, widths =c(1.1, 1, 1, 1))
Trends_Omega

pCO2-All

## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.data$pCO2_uatm
## W = 0.94805, p-value < 2.2e-16

## Model with all data
pCO2_all_o<-lmer(pCO2_uatm~Year * Zone * Sub_region + (1|Month)+           
                                    (1|SiteID), data=Trends.data)
    step(Omega_all_o)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC     LRT Df Pr(>Chisq)    
## <none>                    33 -275.96 617.91                          
## (1 | SiteID)          1   32 -276.49 616.97   1.059  1     0.3035    
## (1 | Month)           0   31 -432.83 927.66 312.693  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                      Eliminated Sum Sq Mean Sq NumDF  DenDF F value    Pr(>F)
## Year:Zone:Sub_region          1 0.1748 0.02185     8 1156.1  0.2736   0.97455
## Year:Sub_region               2 0.0829 0.02764     3 1164.2  0.3478   0.79074
## Year:Zone                     0 0.8539 0.28463     3 1167.1  3.5882   0.01334
## Zone:Sub_region               0 5.8363 0.72953     8 1167.1  9.1967 2.436e-12
##                         
## Year:Zone:Sub_region    
## Year:Sub_region         
## Year:Zone            *  
## Zone:Sub_region      ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## Aragonite_Sat_W ~ Year + Zone + Sub_region + (1 | Month) + Year:Zone + Zone:Sub_region
pCO2_all_o_1<-lmer(pCO2_uatm ~ Year + Zone + Sub_region + (1 | Month) +
                      Year:Zone + Zone:Sub_region, data=Trends.data)

pCO2_all_o_3<-lmer(pCO2_uatm ~ Year + Zone + (1 | Month) + (1|Sub_region)+
                       Year:Zone, data=Trends.data)
    

anova(pCO2_all_o, pCO2_all_o_1, pCO2_all_o_3)
    summary(pCO2_all_o_1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: pCO2_uatm ~ Year + Zone + Sub_region + (1 | Month) + Year:Zone +  
##     Zone:Sub_region
##    Data: Trends.data
## 
## REML criterion at convergence: 12715.8
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.5056 -0.5118 -0.0895  0.4862  5.7438 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 1952     44.19   
##  Residual             2534     50.34   
## Number of obs: 1197, groups:  Month, 12
## 
## Fixed effects:
##                                Estimate Std. Error         df t value Pr(>|t|)
## (Intercept)                    6761.657   2868.834   1175.441   2.357 0.018590
## Year                             -3.135      1.422   1175.416  -2.205 0.027618
## ZoneMid channel               -6144.663   3782.512   1166.923  -1.624 0.104541
## ZoneOffshore                 -11332.404   3601.575   1166.912  -3.147 0.001694
## ZoneOceanic                  -15047.197   4756.872   1166.949  -3.163 0.001600
## Sub_regionUK                    -26.461      8.174   1166.988  -3.237 0.001241
## Sub_regionMK                    -28.997      8.072   1166.994  -3.592 0.000341
## Sub_regionLK                     11.401      8.024   1167.024   1.421 0.155611
## Year:ZoneMid channel              3.036      1.875   1166.923   1.620 0.105562
## Year:ZoneOffshore                 5.607      1.785   1166.912   3.142 0.001722
## Year:ZoneOceanic                  7.442      2.357   1166.949   3.157 0.001637
## ZoneMid channel:Sub_regionUK     11.244     12.268   1167.005   0.917 0.359578
## ZoneOffshore:Sub_regionUK        19.579     11.512   1166.985   1.701 0.089268
## ZoneOceanic:Sub_regionUK         27.594     13.978   1167.012   1.974 0.048600
## ZoneMid channel:Sub_regionMK     18.743     11.411   1166.962   1.643 0.100743
## ZoneOffshore:Sub_regionMK        20.827     11.374   1166.963   1.831 0.067328
## ZoneOceanic:Sub_regionMK         36.058     11.726   1166.977   3.075 0.002153
## ZoneMid channel:Sub_regionLK     -3.927     11.351   1166.959  -0.346 0.729418
## ZoneOffshore:Sub_regionLK       -10.698     11.046   1166.963  -0.969 0.332981
##                                 
## (Intercept)                  *  
## Year                         *  
## ZoneMid channel                 
## ZoneOffshore                 ** 
## ZoneOceanic                  ** 
## Sub_regionUK                 ** 
## Sub_regionMK                 ***
## Sub_regionLK                    
## Year:ZoneMid channel            
## Year:ZoneOffshore            ** 
## Year:ZoneOceanic             ** 
## ZoneMid channel:Sub_regionUK    
## ZoneOffshore:Sub_regionUK    .  
## ZoneOceanic:Sub_regionUK     *  
## ZoneMid channel:Sub_regionMK    
## ZoneOffshore:Sub_regionMK    .  
## ZoneOceanic:Sub_regionMK     ** 
## ZoneMid channel:Sub_regionLK    
## ZoneOffshore:Sub_regionLK       
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## fit warnings:
## fixed-effect model matrix is rank deficient so dropping 1 column / coefficient
    anova(pCO2_all_o_1)
    ranova(pCO2_all_o_1)
# Obtain slopes
    
    ranef(pCO2_all_o_1)
## $Month
##     (Intercept)
## Apr  -56.973217
## May  -54.622146
## Jun    4.627320
## Jul   44.022802
## Aug   33.795553
## Sep   61.345527
## Oct   51.108885
## Nov   21.816965
## Dec    3.170544
## Jan   -9.926005
## Feb  -51.860030
## Mar  -46.506197
## 
## with conditional variances for "Month"
    fixef(pCO2_all_o_1)
##                  (Intercept)                         Year 
##                  6761.657108                    -3.135358 
##              ZoneMid channel                 ZoneOffshore 
##                 -6144.662813                -11332.404129 
##                  ZoneOceanic                 Sub_regionUK 
##                -15047.196693                   -26.461113 
##                 Sub_regionMK                 Sub_regionLK 
##                   -28.996527                    11.401282 
##         Year:ZoneMid channel            Year:ZoneOffshore 
##                     3.036177                     5.607421 
##             Year:ZoneOceanic ZoneMid channel:Sub_regionUK 
##                     7.441633                    11.243785 
##    ZoneOffshore:Sub_regionUK     ZoneOceanic:Sub_regionUK 
##                    19.578823                    27.594357 
## ZoneMid channel:Sub_regionMK    ZoneOffshore:Sub_regionMK 
##                    18.743369                    20.827091 
##     ZoneOceanic:Sub_regionMK ZoneMid channel:Sub_regionLK 
##                    36.057819                    -3.927243 
##    ZoneOffshore:Sub_regionLK 
##                   -10.698358
    coef(pCO2_all_o_1)$Month
    coef(pCO2_all_o_1)$Zone
## NULL
  m.lst <- lstrends(pCO2_all_o_1, "Zone", var="Year")
  m.lst
##  Zone        Year.trend   SE   df lower.CL upper.CL
##  Inshore        -3.1354 1.42 1175   -5.927   -0.344
##  Mid channel    -0.0992 1.47 1175   -2.974    2.776
##  Offshore        2.4721 1.35 1176   -0.168    5.112
##  Oceanic         4.3063 2.04 1171    0.303    8.310
## 
## Results are averaged over the levels of: Sub_region 
## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95
  pairs(m.lst)
##  contrast               estimate   SE   df t.ratio p.value
##  Inshore - Mid channel     -3.04 1.87 1167  -1.620  0.3678
##  Inshore - Offshore        -5.61 1.78 1167  -3.142  0.0093
##  Inshore - Oceanic         -7.44 2.36 1167  -3.157  0.0089
##  Mid channel - Offshore    -2.57 1.82 1167  -1.413  0.4913
##  Mid channel - Oceanic     -4.41 2.38 1167  -1.848  0.2512
##  Offshore - Oceanic        -1.83 2.31 1167  -0.793  0.8577
## 
## Results are averaged over the levels of: Sub_region 
## Degrees-of-freedom method: kenward-roger 
## P value adjustment: tukey method for comparing a family of 4 estimates

Inshore

# Inshore pCO2
  hist(Trends.inshore$pCO2_uatm)

  shapiro.test(Trends.inshore$pCO2_uatm)# Normality NOT? rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.inshore$pCO2_uatm
## W = 0.98938, p-value = 0.01335
  pCO2_in_0<-lmer(pCO2_uatm~Year * Sub_region + (1|Month)+
                                  #(1|Zone)+             
                                  (1|SiteID), data=Trends.inshore)
  #summary(pCO2_in_0)    
  anova(pCO2_in_0)
  ranova(pCO2_in_0)
  step(pCO2_in_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC     LRT Df Pr(>Chisq)    
## <none>                    11 -1915.9 3853.9                          
## (1 | Month)           0   10 -2051.9 4123.8 271.971  1    < 2e-16 ***
## (1 | SiteID)          0   10 -1919.1 3858.2   6.346  1    0.01176 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value Pr(>F)
## Year:Sub_region          1  9819.4  3273.1     3 318.28  0.8174 0.4850
## Year                     2   456.1   456.1     1 330.35  0.1141 0.7358
## Sub_region               3 30485.5 10161.8     3   7.03  2.5490 0.1386
## 
## Model found:
## pCO2_uatm ~ (1 | Month) + (1 | SiteID)
pCO2_in<-lmer(pCO2_uatm ~ (1|Month)+(1|SiteID), data=Trends.inshore)
  summary(pCO2_in)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: pCO2_uatm ~ (1 | Month) + (1 | SiteID)
##    Data: Trends.inshore
## 
## REML criterion at convergence: 3880.4
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.6603 -0.6292 -0.0884  0.5648  3.8565 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 6913.0   83.14   
##  SiteID   (Intercept)  438.5   20.94   
##  Residual             3986.2   63.14   
## Number of obs: 344, groups:  Month, 12; SiteID, 11
## 
## Fixed effects:
##             Estimate Std. Error     df t value Pr(>|t|)    
## (Intercept)   424.33      25.08  12.43   16.92 5.91e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  anova(pCO2_in)
  plot(pCO2_in)

  qqnorm(resid(pCO2_in))

  acf(resid(pCO2_in), main="acf(resid(pCO2 Inshore))")  

  #pCO2_in.emmc<-emmeans(pCO2_in, ~Month)
      #pCO2_in.emmc<-multcomp::cld(pCO2_in.emmc)
      #pCO2_in.emmc<-pCO2_in.emmc[order(pCO2_in.emmc$Sub_region),]
      #pCO2_in.emmc
# Predict values  
  In_pCO2_Pred <- predict(pCO2_in, newdata=In_Newdata, re.form=NA, level=0, asList = FALSE)
  
  In_pCO2_Pred <-cbind(In_Newdata, In_pCO2_Pred)
  In_pCO2_Pred$Date<-as.Date(as.character(In_pCO2_Pred$Year), format = "%Y")
  
# # Model summary
#   slope<-round(
#       summary(pCO2_in)$coefficients["Year", "Estimate"], digits = 3)
#   xs <- as.Date(as.character("2018-11-20"))
#   ys <- max(Trends.midchanel$pCO2_uatm, na.rm =T)
# 
# # Plot raw data point and fitted model 
#   plot_label <- sprintf("\"\" ~ pCO[2] == %0.3f", slope)
#   plot_label2 <- expression("Year^-1")
  
  
# Plot raw data point and fitted model 
  
  In_pCO2_Modeled<-Long_plot2+ facet_grid(~Zone)+
     scale_y_continuous(name=expression(paste(pCO[2], ~" (", mu, " atm)")),
                        limits = c(200,800),
                        breaks = seq(0, 800, 100),  
                        expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.inshore, 
                               aes(y=pCO2_uatm, x=Date, 
                                   #fill = Sub_region), 
                                  colour = Sub_region),  
                                  alpha=0.5, size=0.5, shape=21)+
      geom_line(data=In_pCO2_Pred, aes(y = In_pCO2_Pred,
                                      x=Date), linetype=2, size=1, colour = "black")

  In_pCO2_Modeled

Mid channel

hist(Trends.midchanel$pCO2_uatm)

shapiro.test(Trends.midchanel$pCO2_uatm)# Normality NOT rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.midchanel$pCO2_uatm
## W = 0.99193, p-value = 0.08115
pCO2_mc_0<-lmer(pCO2_uatm~Year * Sub_region + (1|Month) + 
                                  #(1|Zone)+             
                                  (1|SiteID), data=Trends.midchanel)
  #summary(pCO2_mc_0)    
  anova(pCO2_mc_0)
  ranova(pCO2_mc_0)
  step(pCO2_mc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC     LRT Df Pr(>Chisq)    
## <none>                    11 -1596.5 3215.0                          
## (1 | SiteID)          1   10 -1597.2 3214.4   1.427  1     0.2323    
## (1 | Month)           0    9 -1698.7 3415.5 203.028  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value    Pr(>F)    
## Year:Sub_region          1  5119.6  1706.5     3 299.05  1.2591 0.2885697    
## Year                     2   424.7   424.7     1 312.01  0.3126 0.5765201    
## Sub_region               0 25387.8  8462.6     3 303.07  6.2450 0.0003984 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## pCO2_uatm ~ Sub_region + (1 | Month)
pCO2_mc<-lmer(pCO2_uatm ~ Year + Sub_region + (1 | Month), 
              data = Trends.midchanel)
  summary(pCO2_mc) 
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: pCO2_uatm ~ Year + Sub_region + (1 | Month)
##    Data: Trends.midchanel
## 
## REML criterion at convergence: 3209.3
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.0816 -0.6257 -0.1400  0.6184  4.0531 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 1790     42.31   
##  Residual             1359     36.86   
## Number of obs: 318, groups:  Month, 12
## 
## Fixed effects:
##               Estimate Std. Error        df t value Pr(>|t|)  
## (Intercept)  1847.0047  2557.7681  312.0201   0.722   0.4708  
## Year           -0.7086     1.2675  312.0143  -0.559   0.5765  
## Sub_regionUK  -15.5826     6.7090  302.0770  -2.323   0.0209 *
## Sub_regionMK   -9.9211     5.9178  302.0364  -1.676   0.0947 .
## Sub_regionLK    7.6569     5.9080  302.1158   1.296   0.1960  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.019  0.018              
## Sub_reginMK -0.004  0.003  0.528       
## Sub_reginLK -0.026  0.024  0.531  0.602
   anova(pCO2_mc)
   plot(pCO2_mc)

  qqnorm(resid(pCO2_mc))

  acf(resid(pCO2_mc), main="acf(resid(pCO2 Mid Channel))")  

  pCO2_mc.emmc<-emmeans(pCO2_mc, ~Sub_region+Year)
        pCO2_mc.emmc<-multcomp::cld(pCO2_mc.emmc)
        pCO2_mc.emmc<-pCO2_mc.emmc[order(
          pCO2_mc.emmc$Sub_region),]
  pCO2_mc.emmc
  #write.csv(pCO2_mc.emmc, "FLK_results/Model_2_LTpCO2_POST.csv")
# Predict values  
  Mc_pCO2_Pred <- predict(pCO2_mc, newdata=Mc_Newdata, re.form=NA, level=0, asList = FALSE)
  
  Mc_pCO2_Pred <-cbind(Mc_Newdata, Mc_pCO2_Pred)
  Mc_pCO2_Pred$Date<-as.Date(as.character(Mc_pCO2_Pred$Year), format = "%Y")
  
 # Model summary
  slope<-round(
      summary(pCO2_mc)$coefficients["Year", "Estimate"], digits = 3)
  #ys <- max(Trends.inshore$pCO2_uatm, na.rm =T)
  ys <- max(Trends.midchanel$pCO2_uatm, na.rm =T)+50

# Plot raw data point and fitted model 
  plot_label <- sprintf("\"\" ~ pCO[2] == %0.3f", slope)
  plot_label2 <- expression("Year^-1")
  
  
# Plot raw data point and fitted model 
  
  Mc_pCO2_Modeled<-Long_plot2+ facet_grid(~Zone)+
     scale_y_continuous(name=expression(paste(pCO[2], ~" (", mu, " atm)")),
                       limits = c(200,800),
                        breaks = seq(0, 800, 100),  
                        expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.midchanel, 
                               aes(y=pCO2_uatm, x=Date, #fill = Sub_region), 
                                  colour = Sub_region),  
                               alpha=0.5, size=0.5, shape=23)+
      geom_line(data=Mc_pCO2_Pred, aes(y = Mc_pCO2_Pred,
                                      x=Date, colour = Sub_region),
                linetype=1, size=1) +
     annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
               #label = expression("~Omega[Ar] == -0.015** ~Year ^-1"), 
               label =paste0(as.character(plot_label, plot_label2, sep = " ")),
               size=4)
  Mc_pCO2_Modeled

Offshore

hist(Trends.offshore$pCO2_uatm)

shapiro.test(Trends.offshore$pCO2_uatm)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.offshore$pCO2_uatm
## W = 0.98049, p-value = 4.25e-05
pCO2_of_0<-lmer(pCO2_uatm~Year * Sub_region + 
               (1|Month) + (1|SiteID),
               data=Trends.offshore)
  #summary(pCO2_of_0)    
  anova(pCO2_of_0)
  ranova(pCO2_of_0)
  step(pCO2_of_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -1754.3 3530.6                         
## (1 | SiteID)          1   10 -1754.3 3528.6   0.00  1          1    
## (1 | Month)           0    9 -1888.3 3794.7 268.04  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value  Pr(>F)  
## Year:Sub_region          0   4488    1496     3 368.87  3.1239 0.02594 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## pCO2_uatm ~ Year + Sub_region + (1 | Month) + Year:Sub_region
pCO2_of<-lmer(pCO2_uatm ~ Year + Sub_region + (1 | Month),
              data =Trends.offshore)
  summary(pCO2_of)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: pCO2_uatm ~ Year + Sub_region + (1 | Month)
##    Data: Trends.offshore
## 
## REML criterion at convergence: 3525.3
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.8917 -0.6612 -0.0745  0.5456  5.1171 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 792.6    28.15   
##  Residual             487.1    22.07   
## Number of obs: 388, groups:  Month, 12
## 
## Fixed effects:
##                Estimate Std. Error         df t value Pr(>|t|)  
## (Intercept)  -2868.7304  1388.0888   381.0773  -2.067   0.0394 *
## Year             1.6282     0.6879   381.0643   2.367   0.0184 *
## Sub_regionUK    -5.4089     3.5549   371.8480  -1.522   0.1290  
## Sub_regionMK    -8.5154     3.5165   371.8470  -2.422   0.0159 *
## Sub_regionLK     2.0882     3.3455   371.9472   0.624   0.5329  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.008  0.006              
## Sub_reginMK -0.007  0.006  0.590       
## Sub_reginLK -0.021  0.019  0.622  0.630
  anova(pCO2_of)
  plot(pCO2_of)

  qqnorm(resid(pCO2_of))

  acf(resid(Omega_in), main="acf(resid(pCO2 Offshore))")  

  pCO2_of.emmc<-emmeans(pCO2_of, ~Sub_region)
        pCO2_of.emmc<-multcomp::cld(pCO2_of.emmc)
        pCO2_of.emmc<-pCO2_of.emmc[order(pCO2_of.emmc$Sub_region),]
  pCO2_of.emmc
  #write.csv(pCO2_of.emmc, "FLK_results/Model_3_LTpCO2_POST.csv")
# Predict values  
  Of_pCO2_Pred <- predict(pCO2_of, newdata=Of_Newdata, re.form=NA, level=0, asList = FALSE)
  
  Of_pCO2_Pred <-cbind(Of_Newdata, Of_pCO2_Pred)
  Of_pCO2_Pred$Date<-as.Date(as.character(Of_pCO2_Pred$Year), format = "%Y")
  
# Model summary for slope labels 
  slope<-round(
      summary(pCO2_of)$coefficients["Year", "Estimate"], digits = 3)
  #xs <- as.Date(as.character("2018-11-20"))
  ys <- max(Trends.offshore$pCO2_uatm, na.rm =T) -15
  plot_label <- sprintf("\"\" ~ pCO[2] == %0.3f", slope)
  plot_label2 <- expression("Year^-1")
  
# Plot raw data point and fitted model 
  Of_pCO2_Modeled<-Long_plot2+ facet_grid(~Zone)+
     scale_y_continuous(name=expression(paste(pCO[2], ~" (", mu, " atm)")),
                       limits = c(300,605),
                        breaks = seq(0, 800, 100),  
                        expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.offshore, 
                               aes(y=pCO2_uatm, x=Date, 
                                   #fill = Sub_region), 
                                  colour = Sub_region),  
                                alpha=0.5, size=0.5, shape=24)+
      geom_line(data=Of_pCO2_Pred, aes(y = Of_pCO2_Pred,
                                      x=Date, colour = Sub_region),
                linetype=1, size=1) +
     annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
               #label = expression("~Omega[Ar] == -0.015** ~Year ^-1"), 
               label =paste0(as.character(plot_label, plot_label2, sep = " ")),
               size=4)
  Of_pCO2_Modeled

Oceanic

hist(Trends.ocean$pCO2_uatm)

shapiro.test(Trends.ocean$pCO2_uatm)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.ocean$pCO2_uatm
## W = 0.97367, p-value = 0.006268
pCO2_oc_0<-lmer(pCO2_uatm ~ Year * Sub_region + 
               (1 | Month)+ (1|SiteID),
               data=Trends.ocean)
  #summary(pCO2_oc_0)    
  anova(pCO2_oc_0)
  ranova(pCO2_oc_0)
  step(pCO2_oc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                     9 -638.51 1295.0                         
## (1 | SiteID)          1    8 -638.51 1293.0  0.000  1          1    
## (1 | Month)           0    7 -672.07 1358.2 67.127  1  2.546e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value Pr(>F)  
## Year:Sub_region          1  305.77  152.88     2 130.07  0.4532 0.6366  
## Sub_region               2  847.30  423.65     2 132.00  1.2679 0.2848  
## Year                     0 1510.86 1510.86     1 143.84  4.5007 0.0356 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## pCO2_uatm ~ Year + (1 | Month)
pCO2_oc<-lmer(pCO2_uatm ~ Year + (1 | Month), 
              data = Trends.ocean)
  summary(pCO2_oc) 
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: pCO2_uatm ~ Year + (1 | Month)
##    Data: Trends.ocean
## 
## REML criterion at convergence: 1295.2
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -2.68545 -0.58477 -0.03898  0.58620  2.80401 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 388.9    19.72   
##  Residual             335.7    18.32   
## Number of obs: 147, groups:  Month, 12
## 
## Fixed effects:
##               Estimate Std. Error         df t value Pr(>|t|)  
## (Intercept) -3417.6663  1805.0046   143.8374  -1.893   0.0603 .
## Year            1.8977     0.8945   143.8347   2.121   0.0356 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##      (Intr)
## Year -1.000
  anova(pCO2_oc) 
  plot(pCO2_oc)

  qqnorm(resid(pCO2_oc))

  acf(resid(pCO2_oc), main="acf(resid(pCO2 open))")

  pCO2_oc.emmc<-emmeans(pCO2_oc, ~Year)
        pCO2_oc.emmc<-multcomp::cld(pCO2_oc.emmc)
        #pCO2_oc.emmc<-pCO2_oc.emmc[order(pCO2_oc.emmc$Sub_region),]
  pCO2_oc.emmc
# Predict values  
  Oc_pCO2_Pred <- predict(pCO2_oc, newdata=Oc_Newdata, 
                          re.form=NA, level=0, asList = FALSE)
  Oc_pCO2_Pred <-cbind(Oc_Newdata, Oc_pCO2_Pred)
  Oc_pCO2_Pred$Date<-as.Date(as.character(Oc_pCO2_Pred$Year), format = "%Y")
  
# Model summary for slope labels 
  slope<-round(
      summary(pCO2_oc)$coefficients["Year", "Estimate"], digits = 3)
  #xs <- as.Date(as.character("2018-11-20"))
  ys <- max(Trends.offshore$pCO2_uatm, na.rm =T)-15
  plot_label <- sprintf("\"\" ~ pCO[2] == %0.3f", slope)
  plot_label2 <- expression("Year^-1")
  
# Plot raw data point and fitted model 
  Oc_pCO2_Modeled<-Long_plot2+ facet_grid(~Zone)+
     scale_y_continuous(name=expression(paste(pCO[2], ~" (", mu, " atm)")),
                       limits = c(300,605),
                        breaks = seq(0, 800, 100),  
                        expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.ocean, 
                               aes(y=pCO2_uatm, x=Date, #fill = Sub_region), 
                                  colour = Sub_region),  
                                alpha=0.5, size=0.5, shape=25)+
      geom_line(data=Oc_pCO2_Pred, aes(y = Oc_pCO2_Pred, x=Date), 
                          colour = "black", linetype=1, size=1) +
      annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
              label =paste0(as.character(plot_label, plot_label2, sep = " ")),
              size=4)
  Oc_pCO2_Modeled

Models summary

Complete models

# ANOVAs
    # Convert ANOVA results into dataframes allows for easier name manipulation
    
    av.pCO2_in_0 <- data.frame (anova(pCO2_in_0))
    av.pCO2_mc_0 <- data.frame (anova(pCO2_mc_0) )
    av.pCO2_of_0 <- data.frame (anova(pCO2_of_0))
    av.pCO2_oc_0 <- data.frame (anova(pCO2_oc_0))
    
    # Putting all into one dataframe/table
    anova_pH <- data.frame(cbind
                    (c("Year", "Sub_region", "Year:Sub_region", 
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region"), 
                      rbind(av.pCO2_in_0, av.pCO2_mc_0,
                      av.pCO2_of_0, av.pCO2_oc_0))) 
    colnames(anova_pH) <- c("", "Sum Sq", "Mean Sq", "N Df" , "D Df",
                                     "F value", "Pr(>F)")
    row.names(anova_pH) <- NULL
    
    # create HTML table using kableExtra
    anova_pH %>% kable("html", digits=2) %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "pCO2 inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "pCO2 mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "pCO2 offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "pCO2 ocean", 10, 12)  
Sum Sq Mean Sq N Df D Df F value Pr(>F)
pCO2 inshore
Year 403.31 403.31 1 327.14 0.10 0.75
Sub_region 9863.53 3287.84 3 318.29 0.82 0.48
Year:Sub_region 9819.44 3273.15 3 318.28 0.82 0.49
pCO2 mid-channel
Year 289.60 289.60 1 303.67 0.22 0.64
Sub_region 5209.62 1736.54 3 293.74 1.30 0.27
Year:Sub_region 5190.90 1730.30 3 293.74 1.30 0.28
pCO2 offshore
Year 3634.86 3634.86 1 377.77 7.59 0.01
Sub_region 4496.27 1498.76 3 368.89 3.13 0.03
Year:Sub_region 4488.04 1496.01 3 368.89 3.12 0.03
pCO2 ocean
Year 1123.31 1123.31 1 139.52 3.33 0.07
Sub_region 305.88 152.94 2 130.10 0.45 0.64
Year:Sub_region 305.77 152.88 2 130.10 0.45 0.64
# R-ANOVAs    
    rav.pCO2_in_0 <- data.frame (ranova(pCO2_in_0))
    rav.pCO2_mc_0 <- data.frame (ranova(pCO2_mc_0) )
    rav.pCO2_of_0 <- data.frame (ranova(pCO2_of_0))
    rav.pCO2_oc_0 <- data.frame (ranova(pCO2_oc_0))
    
    # Putting all into one dataframe/table
    ranova_pCO2 <- data.frame(cbind
                    (c("<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)"), 
                      rbind(rav.pCO2_in_0, rav.pCO2_mc_0,
                            rav.pCO2_of_0, rav.pCO2_oc_0))) 
    colnames(ranova_pCO2) <- c("", "npar", "logLik", "AIC" , "LRT",
                                     "DF", "Pr(>Chi Sq)")
    row.names(ranova_pCO2) <- NULL
    
    # create HTML table using kableExtra
    ranova_pCO2 %>% kable("html", digits=2) %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Omega inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "Omega mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "Omega offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "Omega ocean", 10, 12)  
npar logLik AIC LRT DF Pr(>Chi Sq)
Omega inshore
<none> 11 -1915.93 3853.87
(1 | Month) 10 -2051.92 4123.84 271.97 1 0.00
(1 | SiteID) 10 -1919.11 3858.21 6.35 1 0.01
Omega mid-channel
<none> 11 -1596.51 3215.02
(1 | Month) 10 -1698.74 3417.47 204.45 1 0.00
(1 | SiteID) 10 -1597.22 3214.45 1.43 1 0.23
Omega offshore
<none> 11 -1754.32 3530.63
(1 | Month) 10 -1888.34 3796.67 268.04 1 0.00
(1 | SiteID) 10 -1754.32 3528.63 0.00 1 1.00
Omega ocean
<none> 9 -638.51 1295.02
(1 | Month) 8 -672.07 1360.15 67.13 1 0.00
(1 | SiteID) 8 -638.51 1293.02 0.00 1 1.00
pCO2_models_0<-list("Inshore" = pCO2_in_0, 
                   "Mid channel" = pCO2_mc_0, 
                   "Offshore" = pCO2_of_0, 
                   "Ocean" = pCO2_oc_0)
modelsummary(pCO2_models_0, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'pCO model outputs (all factors)',
             coef_map=factor_order)
pCO model outputs (all factors)
Inshore Mid channel Offshore Ocean
Year 1.030 0.459 3.299* 1.154
(3.905) (2.287) (1.359) (1.760)
Intercept −1641.939 −509.420 −6239.564* −1922.057
(7879.653) (4615.835) (2741.383) (3552.088)
Upper Keys 4095.178 959.391 3881.748
(9973.579) (6330.034) (3388.676)
Middle Keys −1726.157 −810.299 −181.767 −3044.843
(9673.247) (5599.500) (3356.720) (4051.995)
Lower Keys 11347.243 8340.861 7481.548* −354.996
(9742.322) (5654.208) (3199.251) (4079.280)
Num.Obs. 344 318 388 147
R2 Marg. 0.026 0.030 0.032 0.066
R2 Cond. 0.649 0.591 0.635
AIC 3853.9 3215.0 3530.6 1295.0
BIC 3896.1 3256.4 3574.2 1321.9
ICC 0.6 0.6 0.6
RMSE 61.09 35.26 21.35 17.33
+ p
#modelsummary(Omega_models, estimate = "p.value")

Factors removed models

pCO2_models<-list("Inshore" = pCO2_in, 
                   "Mid channel" = pCO2_mc, 
                   "Offshore" = pCO2_of, 
                   "Ocean" = pCO2_oc)
modelsummary(pCO2_models, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'pCO2 models outputs (dropped factors)',
             coef_map=factor_order)
pCO2 models outputs (dropped factors)
Inshore Mid channel Offshore Ocean
Year −0.709 1.628* 1.898*
(1.268) (0.688) (0.895)
Intercept 424.332*** 1847.005 −2868.730* −3417.666+
(25.078) (2557.768) (1388.089) (1805.005)
Upper Keys −15.583* −5.409
(6.709) (3.555)
Middle Keys −9.921+ −8.515*
(5.918) (3.516)
Lower Keys 7.657 2.088
(5.908) (3.346)
Num.Obs. 344 318 388 147
R2 Marg. 0.000 0.025 0.024 0.022
R2 Cond. 0.648 0.579 0.628 0.547
AIC 3888.4 3223.3 3539.3 1303.2
BIC 3903.8 3249.6 3567.1 1315.1
ICC 0.6 0.6 0.6 0.5
RMSE 61.32 35.95 21.62 17.55
+ p
#modelsummary(pCO2_models, estimate = "p.value")
Trends_pCO2<-ggarrange(In_pCO2_Modeled+ theme(axis.title.x=element_blank(),
                                 axis.text.x=element_blank(),
                                 legend.position = "none"),
                  Mc_pCO2_Modeled + theme(legend.position = "none",
                                 axis.title.y=element_blank(),
                                 axis.text.x=element_blank()),
                                
                  Of_pCO2_Modeled + theme(legend.position = "none",
                                           axis.title.y=element_blank(),
                                           axis.text.x=element_blank()),
                                
                  Oc_pCO2_Modeled + theme(legend.position = "none",
                                           axis.title.y=element_blank(),
                                           axis.text.x=element_blank()),
                  
          labels = c("A"),
          ncol = 4, nrow = 1, widths =c(1.1, 1, 1, 1))
Trends_pCO2

pH-All

## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.data$pH_calculated
## W = 0.9654, p-value = 2.775e-16

## Model with all data
pH_all_o<-lmer(pH_calculated ~ Year * Zone * Sub_region + (1|Month)+           
                                    (1|SiteID), data=Trends.data)
    step(pH_all_o)
## Backward reduced random-effect table:
## 
##              Eliminated npar logLik     AIC    LRT Df Pr(>Chisq)    
## <none>                    33 1936.9 -3807.8                         
## (1 | Month)           0   32 1606.8 -3149.7 660.10  1    < 2e-16 ***
## (1 | SiteID)          0   32 1935.4 -3806.8   2.94  1    0.08666 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                      Eliminated   Sum Sq   Mean Sq NumDF   DenDF F value
## Year:Zone:Sub_region          1 0.001667 0.0002083     8 1134.60  0.1180
## Year:Sub_region               2 0.009967 0.0033223     3 1142.16  1.8934
## Year:Zone                     0 0.031830 0.0106100     3 1145.11  6.0315
## Zone:Sub_region               0 0.038306 0.0047882     8   23.85  2.7220
##                         Pr(>F)    
## Year:Zone:Sub_region 0.9985669    
## Year:Sub_region      0.1288993    
## Year:Zone            0.0004481 ***
## Zone:Sub_region      0.0275848 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## pH_calculated ~ Year + Zone + Sub_region + (1 | Month) + (1 | SiteID) + Year:Zone + Zone:Sub_region
pH_all_o_1<-lmer(pH_calculated ~ Year + Zone + Sub_region + (1 | Month) +
                      Year:Zone + Zone:Sub_region, data=Trends.data)

pH_all_o_3<-lmer(pH_calculated ~ Year + Zone + (1 | Month) + (1|Sub_region)+
                       Year:Zone, data=Trends.data)
    

anova(pH_all_o, pH_all_o_1, pH_all_o_3)
    summary(pH_all_o_1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: pH_calculated ~ Year + Zone + Sub_region + (1 | Month) + Year:Zone +  
##     Zone:Sub_region
##    Data: Trends.data
## 
## REML criterion at convergence: -3972.4
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.0535 -0.5326  0.0664  0.4908  4.7287 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 0.001793 0.04234 
##  Residual             0.001779 0.04218 
## Number of obs: 1197, groups:  Month, 12
## 
## Fixed effects:
##                                Estimate Std. Error         df t value Pr(>|t|)
## (Intercept)                   1.995e+00  2.405e+00  1.174e+03   0.830 0.406953
## Year                          2.990e-03  1.192e-03  1.174e+03   2.509 0.012251
## ZoneMid channel               5.778e+00  3.170e+00  1.167e+03   1.823 0.068581
## ZoneOffshore                  1.070e+01  3.018e+00  1.167e+03   3.547 0.000406
## ZoneOceanic                   1.395e+01  3.986e+00  1.167e+03   3.499 0.000484
## Sub_regionUK                  2.414e-02  6.850e-03  1.167e+03   3.524 0.000441
## Sub_regionMK                  1.623e-02  6.764e-03  1.167e+03   2.399 0.016589
## Sub_regionLK                 -2.512e-02  6.724e-03  1.167e+03  -3.736 0.000196
## Year:ZoneMid channel         -2.859e-03  1.571e-03  1.167e+03  -1.820 0.068980
## Year:ZoneOffshore            -5.301e-03  1.496e-03  1.167e+03  -3.544 0.000409
## Year:ZoneOceanic             -6.896e-03  1.976e-03  1.167e+03  -3.491 0.000499
## ZoneMid channel:Sub_regionUK -1.001e-02  1.028e-02  1.167e+03  -0.973 0.330638
## ZoneOffshore:Sub_regionUK    -1.926e-02  9.647e-03  1.167e+03  -1.996 0.046169
## ZoneOceanic:Sub_regionUK     -4.000e-02  1.171e-02  1.167e+03  -3.415 0.000659
## ZoneMid channel:Sub_regionMK -9.845e-03  9.562e-03  1.167e+03  -1.030 0.303418
## ZoneOffshore:Sub_regionMK    -1.113e-02  9.531e-03  1.167e+03  -1.168 0.243018
## ZoneOceanic:Sub_regionMK     -3.709e-02  9.826e-03  1.167e+03  -3.774 0.000168
## ZoneMid channel:Sub_regionLK  1.383e-02  9.512e-03  1.167e+03   1.454 0.146099
## ZoneOffshore:Sub_regionLK     2.311e-02  9.256e-03  1.167e+03   2.497 0.012667
##                                 
## (Intercept)                     
## Year                         *  
## ZoneMid channel              .  
## ZoneOffshore                 ***
## ZoneOceanic                  ***
## Sub_regionUK                 ***
## Sub_regionMK                 *  
## Sub_regionLK                 ***
## Year:ZoneMid channel         .  
## Year:ZoneOffshore            ***
## Year:ZoneOceanic             ***
## ZoneMid channel:Sub_regionUK    
## ZoneOffshore:Sub_regionUK    *  
## ZoneOceanic:Sub_regionUK     ***
## ZoneMid channel:Sub_regionMK    
## ZoneOffshore:Sub_regionMK       
## ZoneOceanic:Sub_regionMK     ***
## ZoneMid channel:Sub_regionLK    
## ZoneOffshore:Sub_regionLK    *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## fit warnings:
## fixed-effect model matrix is rank deficient so dropping 1 column / coefficient
    anova(pH_all_o_1)
    ranova(pH_all_o_1)
    ranef(pH_all_o_1)
## $Month
##      (Intercept)
## Apr  0.051180906
## May  0.045802555
## Jun -0.013693787
## Jul -0.048114395
## Aug -0.037501103
## Sep -0.058058743
## Oct -0.040662622
## Nov -0.017325016
## Dec  0.001336747
## Jan  0.014498595
## Feb  0.057032096
## Mar  0.045504768
## 
## with conditional variances for "Month"
    fixef(pH_all_o_1)
##                  (Intercept)                         Year 
##                  1.995441784                  0.002990402 
##              ZoneMid channel                 ZoneOffshore 
##                  5.777879110                 10.703787726 
##                  ZoneOceanic                 Sub_regionUK 
##                 13.948737264                  0.024141616 
##                 Sub_regionMK                 Sub_regionLK 
##                  0.016227844                 -0.025118073 
##         Year:ZoneMid channel            Year:ZoneOffshore 
##                 -0.002859224                 -0.005300869 
##             Year:ZoneOceanic ZoneMid channel:Sub_regionUK 
##                 -0.006896163                 -0.010005057 
##    ZoneOffshore:Sub_regionUK     ZoneOceanic:Sub_regionUK 
##                 -0.019255358                 -0.040004474 
## ZoneMid channel:Sub_regionMK    ZoneOffshore:Sub_regionMK 
##                 -0.009845181                 -0.011132693 
##     ZoneOceanic:Sub_regionMK ZoneMid channel:Sub_regionLK 
##                 -0.037087964                  0.013834338 
##    ZoneOffshore:Sub_regionLK 
##                  0.023111739
    coef(pH_all_o_1)$Month
    coef(pH_all_o_1)$Zone
## NULL
  m.lst <- lstrends(pH_all_o_1, "Zone", var="Year")
  m.lst
##  Zone        Year.trend      SE   df lower.CL  upper.CL
##  Inshore       0.002990 0.00119 1174  0.00065  5.33e-03
##  Mid channel   0.000131 0.00123 1174 -0.00228  2.54e-03
##  Offshore     -0.002310 0.00113 1174 -0.00452 -9.71e-05
##  Oceanic      -0.003906 0.00171 1170 -0.00726 -5.51e-04
## 
## Results are averaged over the levels of: Sub_region 
## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95
  pairs(m.lst)
##  contrast               estimate      SE   df t.ratio p.value
##  Inshore - Mid channel   0.00286 0.00157 1167   1.820  0.2642
##  Inshore - Offshore      0.00530 0.00150 1167   3.544  0.0023
##  Inshore - Oceanic       0.00690 0.00198 1167   3.491  0.0028
##  Mid channel - Offshore  0.00244 0.00152 1167   1.601  0.3782
##  Mid channel - Oceanic   0.00404 0.00200 1167   2.021  0.1806
##  Offshore - Oceanic      0.00160 0.00194 1167   0.823  0.8436
## 
## Results are averaged over the levels of: Sub_region 
## Degrees-of-freedom method: kenward-roger 
## P value adjustment: tukey method for comparing a family of 4 estimates
  # Create a new data frame for independent variables  
  Newdata<-expand.grid(Zone=unique(Trends.data$Zone),
                          Sub_region=unique(Trends.data$Sub_region),
                          Year=seq((min(Trends.data$Year)-0), (max(Trends.data$Year)+1)))
  
  # Predict values  
  pH_Pred <- predict(pH_all_o_1, newdata=Newdata, 
                        re.form=NA, level=0, asList = FALSE)
  pH_Pred <-cbind(Newdata, pH_Pred)
  pH_Pred$Date<-as.Date(as.character(pH_Pred$Year), format = "%Y")
  

pH_Modeled<-Long_plot2+ facet_grid(~Zone)+
     scale_y_continuous(name=(expression(pH[calculated])),
                       limits=c(7.80, 8.28),
                       breaks = seq(0, 10, 0.1),  
                       expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.data, 
                               aes(y=pH_calculated, x=Date, 
                                   #fill = Sub_region), 
                                  colour = Sub_region),  
                                alpha=0.5, size=0.5,shape=21)+
      geom_line(data=pH_Pred, aes(y = pH_Pred, x=Date,  colour = Sub_region),
                                linetype=2, size=1) #+
      #annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
      #        label =paste0(as.character(plot_label, plot_label2, sep = " ")),
      #        size=4)
  pH_Modeled

Inshore

# Inshore pH
hist(Trends.inshore$pH_calculated)

shapiro.test(Trends.inshore$pH_calculated)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.inshore$pH_calculated
## W = 0.99278, p-value = 0.09599
pH_in_0<-lmer(pH_calculated~Year * Sub_region + (1|Month)+
                                  #(1|Zone)+             
                                  (1|SiteID),
            data=Trends.inshore)
  #summary(pH_in_0)    
  anova(pH_in_0)
  ranova(pH_in_0)
  step(pH_in_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar logLik     AIC     LRT Df Pr(>Chisq)    
## <none>                    11 472.07 -922.13                          
## (1 | Month)           0   10 319.28 -618.56 305.577  1    < 2e-16 ***
## (1 | SiteID)          0   10 469.57 -919.14   4.998  1    0.02537 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated   Sum Sq   Mean Sq NumDF  DenDF F value  Pr(>F)  
## Year:Sub_region          1 0.005513 0.0018377     3 318.36  0.6869 0.56063  
## Year                     2 0.000129 0.0001292     1 329.30  0.0484 0.82595  
## Sub_region               0 0.043823 0.0146075     3   7.05  5.4908 0.02924 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## pH_calculated ~ Sub_region + (1 | Month) + (1 | SiteID)
pH_in<-lmer(pH_calculated ~ Sub_region + (1 | Month) + (1 | SiteID),
            data=Trends.inshore)
  summary(pH_in)    
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: pH_calculated ~ Sub_region + (1 | Month) + (1 | SiteID)
##    Data: Trends.inshore
## 
## REML criterion at convergence: -981.5
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.7731 -0.6334 -0.0156  0.5966  3.7945 
## 
## Random effects:
##  Groups   Name        Variance  Std.Dev.
##  Month    (Intercept) 0.0056657 0.07527 
##  SiteID   (Intercept) 0.0001457 0.01207 
##  Residual             0.0026604 0.05158 
## Number of obs: 344, groups:  Month, 12; SiteID, 11
## 
## Fixed effects:
##              Estimate Std. Error       df t value Pr(>|t|)    
## (Intercept)   8.02929    0.02421 14.95201 331.714   <2e-16 ***
## Sub_regionUK  0.02205    0.01384  6.99886   1.593    0.155    
## Sub_regionMK  0.01624    0.01378  6.87776   1.178    0.278    
## Sub_regionLK -0.02408    0.01376  6.82725  -1.750    0.125    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Sb_rUK Sb_rMK
## Sub_reginUK -0.336              
## Sub_reginMK -0.338  0.590       
## Sub_reginLK -0.339  0.590  0.595
  anova(pH_in)
  plot(pH_in)

  qqnorm(resid(pH_in))

  acf(resid(pH_in), main="acf(resid(pH Inshore))")  

  pH_in.emmc<-emmeans(pH_in, ~Sub_region)
        pH_in.emmc<-multcomp::cld(pH_in.emmc)
        pH_in.emmc<-pH_in.emmc[order(pH_in.emmc$Sub_region),]
  pH_in.emmc
#write.csv(pH_in.emmc, "FLK_results/Model_5_LTpH_POST.csv")
# Predict values  
  In_pH_Pred <- predict(pH_in, newdata=In_Newdata, 
                        re.form=NA, level=0, asList = FALSE)
    In_pH_Pred <-cbind(In_Newdata, In_pH_Pred)
  In_pH_Pred$Date<-as.Date(as.character(In_pH_Pred$Year), format = "%Y")
  
# Model summary for slope labels 
  # slope<-round(
  #     summary(pH_in)$coefficients["Year", "Estimate"], digits = 3)
  # xs <- as.Date(as.character("2018-11-20"))
  # ys <- max(Trends.inshore$pH_calculated, na.rm =T)
  # plot_label <- sprintf("\"\" ~ pH == %0.3f", slope)
  # plot_label2 <- expression("Year^-1")
  
# Plot raw data point and fitted model 
  In_pH_Modeled<-Long_plot2+ #facet_grid(~Zone)+
     scale_y_continuous(name=(expression(pH[calculated])),
                       limits=c(7.80, 8.28),
                       breaks = seq(0, 10, 0.1),  
                       expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.inshore, 
                               aes(y=pH_calculated, x=Date, 
                                   #fill = Sub_region), 
                                  colour = Sub_region),  
                                alpha=0.5, size=0.5,shape=21)+
      geom_line(data=In_pH_Pred, aes(y = In_pH_Pred, x=Date,  colour = Sub_region),
                                linetype=2, size=1) #+
      #annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
      #        label =paste0(as.character(plot_label, plot_label2, sep = " ")),
      #        size=4)
  In_pH_Modeled

Mid channel

hist(Trends.midchanel$pH_calculated)

shapiro.test(Trends.midchanel$pH_calculated)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.midchanel$pH_calculated
## W = 0.98077, p-value = 0.0002898
pH_mc_0<-lmer(pH_calculated~Year * Sub_region + (1|Month) + 
                                  #(1|Zone)+             
                                  (1|SiteID),
            data=Trends.midchanel)
  #summary(pH_mc_0)    
  anova(pH_mc_0)
  ranova(pH_mc_0)
  step(pH_mc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar logLik     AIC    LRT Df Pr(>Chisq)    
## <none>                    11 578.68 -1135.4                         
## (1 | SiteID)          1   10 578.13 -1136.3   1.10  1     0.2942    
## (1 | Month)           0    9 464.95  -911.9 226.37  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated    Sum Sq   Mean Sq NumDF  DenDF F value    Pr(>F)
## Year:Sub_region          1 0.0031628 0.0010543     3 298.99  0.9743    0.4051
## Year                     2 0.0002549 0.0002549     1 311.15  0.2356    0.6277
## Sub_region               0 0.0279055 0.0093018     3 303.03  8.6244 1.645e-05
##                    
## Year:Sub_region    
## Year               
## Sub_region      ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## pH_calculated ~ Sub_region + (1 | Month)
pH_mc<-lmer(pH_calculated ~ Year + Sub_region + (1 | Month),
            data = Trends.midchanel)
  summary(pH_mc)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: pH_calculated ~ Year + Sub_region + (1 | Month)
##    Data: Trends.midchanel
## 
## REML criterion at convergence: -1184.4
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.4722 -0.6346  0.0314  0.5378  4.1787 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 0.001708 0.04133 
##  Residual             0.001082 0.03289 
## Number of obs: 318, groups:  Month, 12
## 
## Fixed effects:
##                Estimate Std. Error         df t value Pr(>|t|)   
## (Intercept)   6.928e+00  2.287e+00  3.112e+02   3.029  0.00266 **
## Year          5.501e-04  1.133e-03  3.112e+02   0.485  0.62772   
## Sub_regionUK  1.450e-02  5.986e-03  3.020e+02   2.422  0.01602 * 
## Sub_regionMK  6.195e-03  5.280e-03  3.020e+02   1.173  0.24162   
## Sub_regionLK -1.128e-02  5.272e-03  3.021e+02  -2.140  0.03312 * 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.019  0.018              
## Sub_reginMK -0.004  0.003  0.528       
## Sub_reginLK -0.026  0.025  0.531  0.602
  anova(pH_mc)
  plot(pH_mc)

  qqnorm(resid(pH_mc))

  acf(resid(pH_mc), main="acf(resid(pH Mid Channel))")  

  pH_mc.emmc<-emmeans(pH_mc, ~Sub_region)
        pH_mc.emmc<-multcomp::cld(pH_mc.emmc)
        pH_mc.emmc<-pH_mc.emmc[order(pH_mc.emmc$Sub_region),]
  pH_mc.emmc
  #write.csv(pH_mc.emmc, "FLK_results/Model_6_LTpH_POST.csv")
# Predict values  
  Mc_pH_Pred <- predict(pH_mc, newdata=Mc_Newdata, 
                        re.form=NA, level=0, asList = FALSE)
  Mc_pH_Pred <-cbind(Mc_Newdata, Mc_pH_Pred)
  Mc_pH_Pred$Date<-as.Date(as.character(Mc_pH_Pred$Year), format = "%Y")
  
# Model summary for slope labels 
  slope<-round(
      summary(pH_mc)$coefficients["Year", "Estimate"], digits = 3)
  #xs <- as.Date(as.character("2018-11-20"))
  #ys <- max(Trends.inshore$pH_calculated, na.rm =T)
  ys <- max(Trends.midchanel$pH_calculated, na.rm =T)+0.03
  plot_label <- sprintf("\"\" ~ pH == %0.3f", slope)
  plot_label2 <- expression("Year^-1")
  
# Plot raw data point and fitted model 
  Mc_pH_Modeled<-Long_plot2+ #facet_grid(~Zone)+
     scale_y_continuous(name=(expression(pH[calculated])),
                       breaks = seq(0, 10, 0.1),  
                       limits=c(7.80, 8.28),
                       expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.midchanel, 
                               aes(y=pH_calculated, x=Date, 
                                   #fill = Sub_region), 
                                colour = Sub_region),  
                                alpha=0.5, size=0.5, shape=23)+
      geom_line(data=Mc_pH_Pred, aes(y = Mc_pH_Pred, x=Date,  colour = Sub_region),
                                linetype=1, size=1) +
      annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
           label =paste0(as.character(plot_label, plot_label2, sep = " ")),
           size=4)
  Mc_pH_Modeled

Offshore

hist(Trends.offshore$pH_calculated)

shapiro.test(Trends.offshore$pH_calculated)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.offshore$pH_calculated
## W = 0.99092, p-value = 0.01729
pH_of_0<-lmer(pH_calculated~Year * Sub_region + 
               (1|Month) + (1|SiteID),
               data=Trends.offshore)
  #summary(pH_of_0)    
  anova(pH_of_0)
  ranova(pH_of_0)
  step(pH_of_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar logLik     AIC    LRT Df Pr(>Chisq)    
## <none>                    11 920.71 -1819.4                         
## (1 | SiteID)          1   10 920.71 -1821.4   0.00  1          1    
## (1 | Month)           0    9 767.35 -1516.7 306.73  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated    Sum Sq   Mean Sq NumDF  DenDF F value  Pr(>F)  
## Year:Sub_region          0 0.0033325 0.0011108     3 368.84   3.037 0.02913 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## pH_calculated ~ Year + Sub_region + (1 | Month) + Year:Sub_region
pH_of<-lmer(pH_calculated ~ Year + Sub_region + (1 | Month), 
            data =Trends.offshore)
  summary(pH_of)    
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: pH_calculated ~ Year + Sub_region + (1 | Month)
##    Data: Trends.offshore
## 
## REML criterion at convergence: -1867.2
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.5593 -0.5678  0.0880  0.6617  3.0799 
## 
## Random effects:
##  Groups   Name        Variance  Std.Dev.
##  Month    (Intercept) 0.0007452 0.02730 
##  Residual             0.0003717 0.01928 
## Number of obs: 388, groups:  Month, 12
## 
## Fixed effects:
##                Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept)   1.043e+01  1.215e+00  3.800e+02   8.591 2.26e-16 ***
## Year         -1.188e-03  6.019e-04  3.799e+02  -1.973   0.0492 *  
## Sub_regionUK  3.608e-03  3.106e-03  3.719e+02   1.162   0.2461    
## Sub_regionMK  5.338e-03  3.072e-03  3.719e+02   1.738   0.0831 .  
## Sub_regionLK -3.117e-03  2.923e-03  3.719e+02  -1.066   0.2869    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.008  0.006              
## Sub_reginMK -0.007  0.006  0.590       
## Sub_reginLK -0.021  0.019  0.622  0.630
   anova(pH_of)
   plot(pH_of)

  qqnorm(resid(pH_of))

  acf(resid(pH_of), main="acf(resid(pH Offshore))")

  pH_of.emmc<-emmeans(pH_of, ~Sub_region)
        pH_of.emmc<-multcomp::cld(pH_of.emmc)
        pH_of.emmc<-pH_of.emmc[order(pH_of.emmc$Sub_region),]
  pH_of.emmc
 #write.csv(pH_of.emmc, "FLK_results/Model_7_LTpH_POST.csv")
# Predict values  
  Of_pH_Pred <- predict(pH_of, newdata=Of_Newdata, 
                        re.form=NA, level=0, asList = FALSE)
  Of_pH_Pred <-cbind(Of_Newdata, Of_pH_Pred)
  Of_pH_Pred$Date<-as.Date(as.character(Of_pH_Pred$Year), format = "%Y")

# Model summary for slope labels 
  slope<-round(
      summary(pH_of)$coefficients["Year", "Estimate"], digits = 3)
  #ys <- max(Trends.inshore$pH_calculated, na.rm =T)
  ys <- max(Trends.offshore$pH_calculated, na.rm =T)+0.08
  plot_label <- sprintf("\"\" ~ pH == %0.3f", slope)
  plot_label2 <- expression("Year^-1")  
  
# Plot raw data point and fitted model 
  Of_pH_Modeled<-Long_plot2+ #facet_grid(~Zone)+
     scale_y_continuous(name=(expression(pH[calculated])),
                      limits=c(7.88, 8.2),
                      # limits=c(7.80, 8.28),
                       breaks = seq(0, 10, 0.1),  
                       expand = c(0, 0.01)) +
    
      geom_point(data=Trends.offshore, 
                               aes(y=pH_calculated, x=Date, 
                                   #fill = Sub_region), 
                                  colour = Sub_region),  
                               alpha=0.5, size=0.5, shape=24)+
      geom_line(data=Of_pH_Pred, aes(y = Of_pH_Pred, x=Date,  colour = Sub_region),
                                linetype=1, size=1) +
      annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
           label =paste0(as.character(plot_label, plot_label2, sep = " ")),
           size=4)
  Of_pH_Modeled

Oceanic

hist(Trends.ocean$pH_calculated)

shapiro.test(Trends.ocean$pH_calculated)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.ocean$pH_calculated
## W = 0.98038, p-value = 0.03364
pH_oc_0<-lmer(pH_calculated ~ Year * Sub_region + 
               (1 | Month)+ (1|SiteID),
               data=Trends.ocean)
  #summary(pH_oc_0)    
  anova(pH_oc_0)
  ranova(pH_oc_0)
  step(pH_oc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar logLik     AIC    LRT Df Pr(>Chisq)    
## <none>                     9 352.05 -686.11                         
## (1 | SiteID)          1    8 352.05 -688.11  0.000  1          1    
## (1 | Month)           0    7 315.65 -617.29 72.815  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated     Sum Sq    Mean Sq NumDF  DenDF F value Pr(>F)
## Year:Sub_region          1 0.00017053 0.00008527     2 130.03  0.3221 0.7252
## Sub_region               2 0.00065586 0.00032793     2 131.94  1.2531 0.2890
## Year                     3 0.00059507 0.00059507     1 143.36  2.2640 0.1346
## 
## Model found:
## pH_calculated ~ (1 | Month)
pH_oc<-lmer(pH_calculated ~ Year + (1 | Month),
               data=Trends.ocean)
  summary(pH_oc)    
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: pH_calculated ~ Year + (1 | Month)
##    Data: Trends.ocean
## 
## REML criterion at convergence: -742.5
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -2.62360 -0.58071 -0.03828  0.65055  2.63861 
## 
## Random effects:
##  Groups   Name        Variance  Std.Dev.
##  Month    (Intercept) 0.0003381 0.01839 
##  Residual             0.0002628 0.01621 
## Number of obs: 147, groups:  Month, 12
## 
## Fixed effects:
##               Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept)  1.045e+01  1.601e+00  1.434e+02   6.527 1.08e-09 ***
## Year        -1.194e-03  7.935e-04  1.434e+02  -1.505    0.135    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##      (Intr)
## Year -1.000
  anova(pH_oc) 
  plot(pH_oc)

  qqnorm(resid(pH_oc))

  acf(resid(pH_oc), main="acf(resid(pH ocean))")

  pH_oc.emmc<-emmeans(pH_oc, ~Year)
        pH_oc.emmc<-multcomp::cld(pH_oc.emmc)
        #pH_oc.emmc<-pH_oc.emmc[order(pH_oc.emmc$Sub_region),]
  pH_oc.emmc
# Predict values  
  Oc_pH_Pred <- predict(pH_oc, newdata=Oc_Newdata,
                        re.form=NA, level=0, asList = FALSE)
  Oc_pH_Pred <-cbind(Oc_Newdata, Oc_pH_Pred)
  Oc_pH_Pred$Date<-as.Date(as.character(Oc_pH_Pred$Year), format = "%Y")

# Model summary for slope labels 
  slope<-round(
      summary(pH_oc)$coefficients["Year", "Estimate"], digits = 3)
  #ys <- max(Trends.inshore$pH_calculated, na.rm =T)
  ys <- max(Trends.offshore$pH_calculated, na.rm =T)+0.08
  plot_label <- sprintf("\"\" ~ pH == %0.3f", slope)
  plot_label2 <- expression("Year^-1")  
  
# Plot raw data point and fitted model 
  Oc_pH_Modeled<-Long_plot2+ #facet_grid(~Zone)+
     scale_y_continuous(name=(expression(pH[calculated])),
                      limits=c(7.88, 8.2),
                      # limits=c(7.80, 8.28),
                       breaks = seq(0, 10, 0.1),  
                       expand = c(0, 0.01)) +
    
      geom_point(data=Trends.ocean, 
                               aes(y=pH_calculated, x=Date, #fill = Sub_region), 
                                  colour = Sub_region),  
                                alpha=0.5, size=0.5, shape=25)+
      geom_line(data=Oc_pH_Pred, aes(y = Oc_pH_Pred, x=Date),
                                linetype=1, size=1, colour = "black") +
      annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
           label =paste0(as.character(plot_label, plot_label2, sep = " ")),
           size=4)
  Oc_pH_Modeled

Models summary

Complete models

# ANOVAs
    # Convert ANOVA results into dataframes allows for easier name manipulation
    av.pH_in_0 <- data.frame (anova(pH_in_0))
    av.pH_mc_0 <- data.frame (anova(pH_mc_0) )
    av.pH_of_0 <- data.frame (anova(pH_of_0))
    av.pH_oc_0 <- data.frame (anova(pH_oc_0))
    
    # Putting all into one dataframe/table
    anova_pH <- data.frame(cbind
                    (c("Year", "Sub_region", "Year:Sub_region", 
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region"), 
                         rbind(av.pH_in_0, av.pH_mc_0,
                         av.pH_of_0, av.pH_oc_0))) 
    colnames(anova_pH) <- c("", "Sum Sq", "Mean Sq", "N Df" , "D Df",
                                     "F value", "Pr(>F)")
    row.names(anova_pH) <- NULL
  
  # create HTML table using kableExtra
  anova_pH %>% kable("html", digits=2) %>% 
  kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "pH inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "pH mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "pH offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "pH ocean", 10, 12)  
Sum Sq Mean Sq N Df D Df F value Pr(>F)
pH inshore
Year 0.00 0 1 326.18 0.01 0.91
Sub_region 0.01 0 3 318.36 0.69 0.56
Year:Sub_region 0.01 0 3 318.36 0.69 0.56
pH mid-channel
Year 0.00 0 1 302.76 0.13 0.72
Sub_region 0.00 0 3 293.60 1.00 0.39
Year:Sub_region 0.00 0 3 293.60 1.00 0.39
pH offshore
Year 0.00 0 1 376.66 5.67 0.02
Sub_region 0.00 0 3 368.90 3.04 0.03
Year:Sub_region 0.00 0 3 368.90 3.04 0.03
pH ocean
Year 0.00 0 1 139.04 1.51 0.22
Sub_region 0.00 0 2 130.03 0.32 0.73
Year:Sub_region 0.00 0 2 130.03 0.32 0.73
# R-ANOVAs    
    rav.pH_in_0 <- data.frame (ranova(pH_in_0))
    rav.pH_mc_0 <- data.frame (ranova(pH_mc_0) )
    rav.pH_of_0 <- data.frame (ranova(pH_of_0))
    rav.pH_oc_0 <- data.frame (ranova(pH_oc_0))
    
    # Putting all into one dataframe/table
    ranova_pH <- data.frame(cbind
                    (c("<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)"), 
                      rbind(rav.pH_in_0, rav.pH_mc_0,
                            rav.pH_of_0, rav.pH_oc_0))) 
    colnames(ranova_pH) <- c("", "npar", "logLik", "AIC" , "LRT",
                                     "DF", "Pr(>Chi Sq)")
    row.names(ranova_pH) <- NULL
    
    # create HTML table using kableExtra
    ranova_pH %>% kable("html", digits=2) %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "pH inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "pH mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "pH offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "pH ocean", 10, 12)  
npar logLik AIC LRT DF Pr(>Chi Sq)
pH inshore
<none> 11 472.07 -922.13
(1 | Month) 10 319.28 -618.56 305.58 1 0.00
(1 | SiteID) 10 469.57 -919.14 5.00 1 0.03
pH mid-channel
<none> 11 578.68 -1135.37
(1 | Month) 10 464.95 -909.90 227.47 1 0.00
(1 | SiteID) 10 578.13 -1136.27 1.10 1 0.29
pH offshore
<none> 11 920.71 -1819.43
(1 | Month) 10 767.35 -1514.69 306.73 1 0.00
(1 | SiteID) 10 920.71 -1821.43 0.00 1 1.00
pH ocean
<none> 9 352.05 -686.11
(1 | Month) 8 315.65 -615.29 72.81 1 0.00
(1 | SiteID) 8 352.05 -688.11 0.00 1 1.00
pH_models_0<-list("Inshore" = pH_in_0, 
                   "Mid channel" = pH_mc_0, 
                   "Offshore" = pH_of_0, 
                   "Ocean" = pH_oc_0)
modelsummary(pH_models_0, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'pH model outputs (all factors)',
             coef_map=factor_order)
pH model outputs (all factors)
Inshore Mid channel Offshore Ocean
Year −0.002 −0.001 −0.003* 0.000
(0.003) (0.002) (0.001) (0.002)
Intercept 12.801* 9.924* 13.706*** 8.959**
(6.444) (4.132) (2.397) (3.149)
Upper Keys −3.966 −1.882 −3.793
(8.152) (5.663) (2.962)
Middle Keys −5.637 −1.331 −0.425 2.596
(7.907) (5.009) (2.934) (3.590)
Lower Keys −11.099 −7.659 −6.779* 0.871
(7.963) (5.058) (2.796) (3.613)
Num.Obs. 344 318 388 147
R2 Marg. 0.041 0.034 0.024 0.044
R2 Cond. 0.697 0.632 0.678
AIC −922.1 −1135.4 −1819.4 −686.1
BIC −879.9 −1094.0 −1775.9 −659.2
ICC 0.7 0.6 0.7
RMSE 0.05 0.03 0.02 0.02
+ p
#modelsummary(pH_models, estimate = "p.value")

Factors removed models

pH_models<-list("Inshore" = pH_in, 
                   "Mid channel" = pH_mc, 
                   "Offshore" = pH_of, 
                   "Ocean" = pH_oc)
modelsummary(pH_models, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'pH model outputs (factors dropped)',
             coef_map=factor_order)
pH model outputs (factors dropped)
Inshore Mid channel Offshore Ocean
Year 0.001 −0.001* −0.001
(0.001) (0.001) (0.001)
Intercept 8.029*** 6.928** 10.434*** 10.450***
(0.024) (2.287) (1.215) (1.601)
Upper Keys 0.022 0.014* 0.004
(0.014) (0.006) (0.003)
Middle Keys 0.016 0.006 0.005+
(0.014) (0.005) (0.003)
Lower Keys −0.024+ −0.011* −0.003
(0.014) (0.005) (0.003)
Num.Obs. 344 318 388 147
R2 Marg. 0.039 0.031 0.016 0.011
R2 Cond. 0.698 0.624 0.673 0.567
AIC −967.5 −1170.4 −1853.2 −734.5
BIC −940.6 −1144.0 −1825.5 −722.5
ICC 0.7 0.6 0.7 0.6
RMSE 0.05 0.03 0.02 0.02
+ p
#modelsummary(pH_models, estimate = "p.value")
Trends_pH<-ggarrange(In_pH_Modeled+ theme(axis.title.x=element_blank(),
                                 axis.text.x=element_blank(),
                                 legend.position = "none"),
                  Mc_pH_Modeled + theme(legend.position = "none",
                                 axis.text.x=element_blank(),
                                  axis.title.y=element_blank()),
                                
                  Of_pH_Modeled + theme(legend.position = "none",
                                        axis.text.x=element_blank(),
                                        axis.title.y=element_blank()),
                                
                  Oc_pH_Modeled + theme(legend.position = "none",
                                        axis.text.x=element_blank(),
                                        axis.title.y=element_blank()),
                  
          labels = c("B"),
          ncol = 4, nrow = 1, widths =c(1.1, 1, 1, 1))
Trends_pH

TA-All

## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.data$TA_umol_kg
## W = 0.81838, p-value < 2.2e-16

Inshore

# Inshore TA
hist(Trends.inshore$TA_umol_kg)

shapiro.test(Trends.inshore$TA_umol_kg)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.inshore$TA_umol_kg
## W = 0.97801, p-value = 3.91e-05
TA_in_0<-lmer(TA_umol_kg~Year * Sub_region + (1|Month)+
                                  #(1|Zone)+             
                                  (1|SiteID), data=Trends.inshore)
  #summary(TA_in_0)    
  anova(TA_in_0)
  ranova(TA_in_0)
  step(TA_in_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -1945.9 3913.9                         
## (1 | SiteID)          1   10 -1946.6 3913.2   1.36  1     0.2435    
## (1 | Month)           0    9 -2024.9 4067.7 156.49  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value Pr(>F)    
## Year:Sub_region          1  24810    8270     3 326.96  1.7632 0.1540    
## Year                     2    101     101     1 340.99  0.0214 0.8838    
## Sub_region               0 519887  173296     3 331.02 36.8010 <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## TA_umol_kg ~ Sub_region + (1 | Month)
TA_in<-lmer(TA_umol_kg ~ Sub_region + (1 | Month), 
            data=Trends.inshore)
  summary(TA_in)    
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: TA_umol_kg ~ Sub_region + (1 | Month)
##    Data: Trends.inshore
## 
## REML criterion at convergence: 3916.5
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.4979 -0.5647  0.0543  0.5822  3.3187 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 4279     65.41   
##  Residual             4709     68.62   
## Number of obs: 346, groups:  Month, 12
## 
## Fixed effects:
##              Estimate Std. Error       df t value Pr(>|t|)    
## (Intercept)  2375.311     20.710   14.442 114.692  < 2e-16 ***
## Sub_regionUK    3.082     11.147  330.950   0.277  0.78233    
## Sub_regionMK  -33.793     11.016  330.953  -3.068  0.00234 ** 
## Sub_regionLK  -91.997     10.922  331.046  -8.423 1.13e-15 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Sb_rUK Sb_rMK
## Sub_reginUK -0.306              
## Sub_reginMK -0.310  0.573       
## Sub_reginLK -0.313  0.576  0.588
  plot(TA_in)

  qqnorm(resid(TA_in))

  acf(resid(TA_in), main="acf(resid(TA Inshore))") 

  TA_in.emmc<-emmeans(TA_in, ~Sub_region)
        TA_in.emmc<-multcomp::cld(TA_in.emmc)
        TA_in.emmc<-TA_in.emmc[order(TA_in.emmc$Sub_region),]
  TA_in.emmc

Mid channel

hist(Trends.midchanel$TA_umol_kg)

shapiro.test(Trends.midchanel$TA_umol_kg)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.midchanel$TA_umol_kg
## W = 0.87233, p-value = 1.26e-15
TA_mc_0<-lmer(TA_umol_kg~Year * Sub_region + (1|Month) + 
                                  #(1|Zone)+             
                                  (1|SiteID),
            data=Trends.midchanel)
  #summary(TA_mc_0)    
  anova(TA_mc_0)
  ranova(TA_mc_0)
  step(TA_mc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -1659.6 3341.2                         
## (1 | Month)           0   10 -1697.0 3414.0 74.769  1    < 2e-16 ***
## (1 | SiteID)          0   10 -1661.0 3342.1  2.857  1    0.09095 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF   DenDF F value  Pr(>F)  
## Year:Sub_region          1  6542.6  2180.9     3 295.170  1.1323 0.33623  
## Year                     2   596.7   596.7     1 304.769  0.3093 0.57854  
## Sub_region               0 27458.2  9152.7     3   6.241  4.7458 0.04778 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## TA_umol_kg ~ Sub_region + (1 | Month) + (1 | SiteID)
TA_mc<-lmer(TA_umol_kg ~ (1 | Month) + (1|SiteID), 
            data = Trends.midchanel)
  summary(TA_mc) 
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: TA_umol_kg ~ (1 | Month) + (1 | SiteID)
##    Data: Trends.midchanel
## 
## REML criterion at convergence: 3367
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -5.0951 -0.4479  0.1143  0.5291  3.4663 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept)  904.3   30.07   
##  SiteID   (Intercept)  248.8   15.77   
##  Residual             1929.2   43.92   
## Number of obs: 320, groups:  Month, 12; SiteID, 10
## 
## Fixed effects:
##             Estimate Std. Error      df t value Pr(>|t|)    
## (Intercept)  2362.46      10.34   15.71   228.4   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  plot(TA_mc)

  qqnorm(resid(TA_mc))

  acf(resid(TA_mc), main="acf(resid(TA Mid Channel))") 

Offshore

hist(Trends.offshore$TA_umol_kg)

shapiro.test(Trends.offshore$TA_umol_kg)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.offshore$TA_umol_kg
## W = 0.88004, p-value < 2.2e-16
TA_of_0<-lmer(TA_umol_kg~Year * Sub_region + 
               (1|Month) + (1|SiteID),
               data=Trends.offshore)
  #summary(TA_of_0)    
  anova(TA_of_0)
  ranova(TA_of_0)
  step(TA_of_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -1681.9 3385.8                         
## (1 | SiteID)          1   10 -1681.9 3383.8  0.000  1          1    
## (1 | Month)           0    9 -1712.8 3443.7 61.928  1  3.562e-15 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value  Pr(>F)  
## Year:Sub_region          1  193.64   64.55     3 371.60  0.2024 0.89468  
## Year                     2    3.81    3.81     1 366.89  0.0120 0.91276  
## Sub_region               0 2944.96  981.65     3 376.33  3.1051 0.02658 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## TA_umol_kg ~ Sub_region + (1 | Month)
TA_of<-lmer(TA_umol_kg ~ Year + Sub_region + (1 | Month), 
            data =Trends.offshore)
  summary(TA_of)    
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: TA_umol_kg ~ Year + Sub_region + (1 | Month)
##    Data: Trends.offshore
## 
## REML criterion at convergence: 3370.5
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -5.6937 -0.3550  0.0732  0.5895  3.5239 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 111.4    10.56   
##  Residual             316.8    17.80   
## Number of obs: 391, groups:  Month, 12
## 
## Fixed effects:
##                Estimate Std. Error         df t value Pr(>|t|)  
## (Intercept)  2498.26924 1087.51333  366.86056   2.297   0.0222 *
## Year           -0.05908    0.53893  366.88694  -0.110   0.9128  
## Sub_regionUK    0.27805    2.86697  374.57369   0.097   0.9228  
## Sub_regionMK   -6.12303    2.83594  374.56360  -2.159   0.0315 *
## Sub_regionLK   -4.77981    2.69007  375.14829  -1.777   0.0764 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.007  0.006              
## Sub_reginMK -0.007  0.006  0.590       
## Sub_reginLK -0.014  0.012  0.624  0.632
  plot(TA_of)

  qqnorm(resid(TA_of))

  acf(resid(TA_of), main="acf(resid(TA Offshore))") 

  TA_of.emmc<-emmeans(TA_of, ~Sub_region)
        TA_of.emmc<-multcomp::cld(TA_of.emmc)
        TA_of.emmc<-TA_of.emmc[order(TA_of.emmc$Sub_region),]
  TA_of.emmc

Oceanic

hist(Trends.ocean$TA_umol_kg)

shapiro.test(Trends.ocean$TA_umol_kg)# Normality NOT rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.ocean$TA_umol_kg
## W = 0.98763, p-value = 0.2082
TA_oc_0<-lmer(TA_umol_kg ~ Year * Sub_region + 
               (1 | Month)+ (1|SiteID),
               data=Trends.ocean)
  #summary(TA_oc_0)    
  anova(TA_oc_0)
  ranova(TA_oc_0)
  step(TA_oc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                     9 -553.79 1125.6                         
## (1 | SiteID)          1    8 -553.79 1123.6  0.000  1  0.9999833    
## (1 | Month)           0    7 -560.39 1134.8 13.207  1  0.0002789 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value  Pr(>F)  
## Year:Sub_region          1  78.07   39.03     2 133.08  0.3885 0.67885  
## Sub_region               2 346.32  173.16     2 134.86  1.7378 0.17982  
## Year                     0 436.28  436.28     1 134.44  4.3181 0.03961 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## TA_umol_kg ~ Year + (1 | Month)
TA_oc<-lmer(TA_umol_kg ~ (1 | Month), 
            data = Trends.ocean)
  summary(TA_oc)    
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: TA_umol_kg ~ (1 | Month)
##    Data: Trends.ocean
## 
## REML criterion at convergence: 1126
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.0590 -0.5199  0.1027  0.5590  2.7345 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept)  30.24    5.499  
##  Residual             102.01   10.100  
## Number of obs: 149, groups:  Month, 12
## 
## Fixed effects:
##             Estimate Std. Error       df t value Pr(>|t|)    
## (Intercept) 2380.537      1.811   10.672    1315   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  plot(TA_oc)

  qqnorm(resid(TA_oc))

  acf(resid(TA_oc), main="acf(resid(TA_Ocean))")

  # TA_oc.emmc<-emmeans(TA_oc, ~Sub_region)
  #       TA_oc.emmc<-multcomp::cld(TA_oc.emmc)
  #       TA_oc.emmc<-TA_oc.emmc[order(TA_oc.emmc$Sub_region),]
  # TA_oc.emmc

Models summary

Complete models

# ANOVAs
    # Convert ANOVA results into dataframes allows for easier name manipulation
    av.TA_in_0 <- data.frame (anova(TA_in_0))
    av.TA_mc_0 <- data.frame (anova(TA_mc_0) )
    av.TA_of_0 <- data.frame (anova(TA_of_0))
    av.TA_oc_0 <- data.frame (anova(TA_oc_0))
    
    # Putting all into one dataframe/table
    anova_TA_0 <- data.frame(cbind
                    (c("Year", "Sub_region", "Year:Sub_region", 
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region"), 
                                      rbind(av.TA_in_0, av.TA_mc_0,
                                            av.TA_of_0, av.TA_oc_0))) 
    colnames(anova_TA_0) <- c("", "Sum Sq", "Mean Sq", "N Df" , "D Df",
                                     "F value", "Pr(>F)")
    row.names(anova_TA_0) <- NULL
    
    # create HTML table using kableExtra
    anova_TA_0 %>% kable("html", digits=2) %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "TA inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "TA mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "TA offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "TA ocean", 10, 12)  
Sum Sq Mean Sq N Df D Df F value Pr(>F)
TA inshore
Year 2.42 2.42 1 332.03 0.00 0.98
Sub_region 25039.93 8346.64 3 320.66 1.81 0.15
Year:Sub_region 25059.97 8353.32 3 320.66 1.81 0.15
TA mid-channel
Year 1034.52 1034.52 1 302.96 0.54 0.46
Sub_region 6543.03 2181.01 3 295.17 1.13 0.34
Year:Sub_region 6542.65 2180.88 3 295.17 1.13 0.34
TA offshore
Year 15.13 15.13 1 366.42 0.05 0.83
Sub_region 194.42 64.81 3 371.64 0.20 0.89
Year:Sub_region 193.64 64.55 3 371.64 0.20 0.89
TA ocean
Year 427.14 427.14 1 135.62 4.25 0.04
Sub_region 77.74 38.87 2 133.07 0.39 0.68
Year:Sub_region 78.07 39.03 2 133.07 0.39 0.68
# R-ANOVAs    
    rav.TA_in_0 <- data.frame (ranova(TA_in_0))
    rav.TA_mc_0 <- data.frame (ranova(TA_mc_0) )
    rav.TA_of_0 <- data.frame (ranova(TA_of_0))
    rav.TA_oc_0 <- data.frame (ranova(TA_oc_0))
    
# Putting all into one dataframe/table
  ranova_TA_0 <- data.frame(cbind
                  (c("<none>", "(1 | Month)", "(1 | SiteID)",
                     "<none>", "(1 | Month)", "(1 | SiteID)",
                     "<none>", "(1 | Month)", "(1 | SiteID)",
                     "<none>", "(1 | Month)", "(1 | SiteID)"), 
               rbind(rav.TA_in_0, rav.TA_mc_0,
                            rav.TA_of_0, rav.TA_oc_0))) 
    colnames(ranova_TA_0) <- c("", "npar", "logLik", "AIC" , "LRT",
                                     "DF", "Pr(>Chi Sq)")
    row.names(ranova_TA_0) <- NULL
    
    # create HTML table using kableExtra
    ranova_TA_0 %>% kable("html", digits=2) %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "TA inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "TA mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "TA offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "TA ocean", 10, 12)
npar logLik AIC LRT DF Pr(>Chi Sq)
TA inshore
<none> 11 -1945.93 3913.87
(1 | Month) 10 -2024.86 4069.72 157.85 1 0.00
(1 | SiteID) 10 -1946.61 3913.23 1.36 1 0.24
TA mid-channel
<none> 11 -1659.60 3341.20
(1 | Month) 10 -1696.99 3413.97 74.77 1 0.00
(1 | SiteID) 10 -1661.03 3342.06 2.86 1 0.09
TA offshore
<none> 11 -1681.89 3385.78
(1 | Month) 10 -1712.85 3445.71 61.93 1 0.00
(1 | SiteID) 10 -1681.89 3383.78 0.00 1 1.00
TA ocean
<none> 9 -553.79 1125.58
(1 | Month) 8 -560.39 1136.79 13.21 1 0.00
(1 | SiteID) 8 -553.79 1123.58 0.00 1 1.00
TA_models_0<-list("Inshore" = TA_in_0, 
                   "Mid channel" = TA_mc_0, 
                   "Offshore" = TA_of_0, 
                   "Ocean" = TA_oc_0)
modelsummary(TA_models_0, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'TA model outputs (all factors)',
             coef_map=factor_order)
TA model outputs (all factors)
Inshore Mid channel Offshore Ocean
Year −1.960 −1.660 −0.782 1.276
(4.183) (2.736) (1.101) (0.943)
Intercept 6329.685 5725.313 3957.018+ −192.795
(8441.085) (5520.064) (2222.111) (1902.437)
Upper Keys 300.228 1795.966 −1817.493
(10704.748) (7610.829) (2764.945)
Middle Keys −17544.634+ −8096.830 −1984.851 158.856
(10383.855) (6732.092) (2738.961) (2205.279)
Lower Keys 1722.170 1762.614 −1551.341 1520.525
(10413.534) (6768.064) (2600.459) (2215.788)
Num.Obs. 346 320 391 149
R2 Marg. 0.152 0.070 0.025 0.063
R2 Cond. 0.566 0.396
AIC 3913.9 3341.2 3385.8 1125.6
BIC 3956.2 3382.7 3429.4 1152.6
ICC 0.5 0.4
RMSE 65.79 42.39 17.44 9.54
+ p
#modelsummary(TA_models, estimate = "p.value")

Factors removed models

TA_models<-list("Inshore" = TA_in, 
                   "Mid channel" = TA_mc, 
                   "Offshore" = TA_of, 
                   "Ocean" = TA_oc)
modelsummary(TA_models, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'TA model outputs (dropped facators)',
             coef_map=factor_order)
TA model outputs (dropped facators)
Inshore Mid channel Offshore Ocean
Year −0.059
(0.539)
Intercept 2375.311*** 2362.465*** 2498.269* 2380.537***
(20.710) (10.342) (1087.513) (1.811)
Upper Keys 3.082 0.278
(11.147) (2.867)
Middle Keys −33.793** −6.123*
(11.016) (2.836)
Lower Keys −91.997*** −4.780+
(10.922) (2.690)
Num.Obs. 346 320 391 149
R2 Marg. 0.146 0.000 0.018 0.000
R2 Cond. 0.552 0.374 0.273 0.229
AIC 3928.5 3375.0 3384.5 1132.0
BIC 3951.6 3390.1 3412.3 1141.1
ICC 0.5 0.4 0.3 0.2
RMSE 67.16 42.65 17.46 9.77
+ p
#modelsummary(TA_models, estimate = "p.value")

DIC-All

## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.data$DIC_umol_kg
## W = 0.89265, p-value < 2.2e-16

Inshore

hist(Trends.inshore$DIC_umol_kg)

shapiro.test(Trends.inshore$DIC_umol_kg)# Normality NOT rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.inshore$DIC_umol_kg
## W = 0.99743, p-value = 0.8723
# Inshore DIC
DIC_in<-lmer(DIC_umol_kg~Year * Sub_region + (1|Month)+
                                  #(1|Zone)+             
                                  (1|SiteID),
             data=Trends.inshore)
  #summary(DIC_in)    
  anova(DIC_in)
  ranova(DIC_in)
  step(DIC_in)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC     LRT Df Pr(>Chisq)    
## <none>                    11 -1944.8 3911.6                          
## (1 | Month)           0   10 -2065.7 4151.4 241.828  1    < 2e-16 ***
## (1 | SiteID)          0   10 -1947.4 3914.7   5.107  1    0.02382 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value  Pr(>F)  
## Year:Sub_region          1  25840  8613.2     3 318.54  1.7970 0.14761  
## Year                     2    419   419.5     1 331.50  0.0869 0.76838  
## Sub_region               0  89217 29739.1     3   7.19  6.1767 0.02126 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## DIC_umol_kg ~ Sub_region + (1 | Month) + (1 | SiteID)
DIC_in<-lmer(DIC_umol_kg ~ Year + Sub_region +
               (1|Month) + (1|SiteID), data=Trends.inshore)
  summary(DIC_in)    
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: DIC_umol_kg ~ Year + Sub_region + (1 | Month) + (1 | SiteID)
##    Data: Trends.inshore
## 
## REML criterion at convergence: 3909.6
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.4187 -0.6488 -0.0022  0.6496  2.7936 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 6878.9   82.94   
##  SiteID   (Intercept)  261.7   16.18   
##  Residual             4829.2   69.49   
## Number of obs: 344, groups:  Month, 12; SiteID, 11
## 
## Fixed effects:
##               Estimate Std. Error        df t value Pr(>|t|)   
## (Intercept)   675.9450  4678.1870  331.5171   0.144  0.88520   
## Year            0.6833     2.3182  331.5036   0.295  0.76838   
## Sub_regionUK  -16.4631    18.5970    7.1538  -0.885  0.40479   
## Sub_regionMK  -46.2885    18.5087    7.0228  -2.501  0.04083 * 
## Sub_regionLK  -70.7519    18.4783    6.9754  -3.829  0.00651 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.026  0.024              
## Sub_reginMK -0.013  0.010  0.590       
## Sub_reginLK -0.023  0.021  0.591  0.595
  plot(DIC_in)

  qqnorm(resid(DIC_in))

  acf(resid(DIC_in), main="acf(resid(DIC Inshore))") 

  DIC_in.emmc<-emmeans(DIC_in, ~Sub_region+Year)
         DIC_in.emmc<-multcomp::cld(DIC_in.emmc)
         DIC_in.emmc<-DIC_in.emmc[order(DIC_in.emmc$Sub_region),]
  DIC_in.emmc

Mid channel

hist(Trends.midchanel$DIC_umol_kg)

shapiro.test(Trends.midchanel$DIC_umol_kg)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.midchanel$DIC_umol_kg
## W = 0.93354, p-value = 1.006e-10
DIC_mc<-lmer(DIC_umol_kg~Year * Sub_region + (1|Month) + 
                                  #(1|Zone)+             
                                  (1|SiteID), data=Trends.midchanel)
  #summary(DIC_mc)    
  anova(DIC_mc)
  ranova(DIC_mc)
  step(DIC_mc)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC     LRT Df Pr(>Chisq)    
## <none>                    11 -1658.0 3338.0                          
## (1 | SiteID)          1   10 -1658.7 3337.3   1.392  1     0.2381    
## (1 | Month)           0    9 -1723.8 3465.6 130.301  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value   Pr(>F)   
## Year:Sub_region          1  8969.4  2989.8     3 298.83  1.4612 0.225205   
## Year                     2  2116.7  2116.7     1 312.94  1.0294 0.311081   
## Sub_region               0 29687.4  9895.8     3 303.09  4.8018 0.002777 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## DIC_umol_kg ~ Sub_region + (1 | Month)
DIC_mc<-lmer(DIC_umol_kg ~ Year + Sub_region + (1 | Month), 
             data = Trends.midchanel)
  summary(DIC_mc) 
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: DIC_umol_kg ~ Year + Sub_region + (1 | Month)
##    Data: Trends.midchanel
## 
## REML criterion at convergence: 3334
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.3673 -0.4419  0.0603  0.5355  3.9086 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 1701     41.24   
##  Residual             2056     45.35   
## Number of obs: 318, groups:  Month, 12
## 
## Fixed effects:
##              Estimate Std. Error       df t value Pr(>|t|)    
## (Intercept)  5217.407   3124.726  312.935   1.670 0.095975 .  
## Year           -1.571      1.548  312.936  -1.015 0.311081    
## Sub_regionUK   -8.845      8.252  301.917  -1.072 0.284641    
## Sub_regionMK  -21.745      7.279  301.853  -2.987 0.003045 ** 
## Sub_regionLK  -24.605      7.267  301.979  -3.386 0.000803 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.019  0.018              
## Sub_reginMK -0.004  0.003  0.528       
## Sub_reginLK -0.025  0.024  0.531  0.602
  plot(DIC_mc)

  qqnorm(resid(DIC_mc))

  acf(resid(DIC_mc), main="acf(resid(DIC Mid Channel))") 

  DIC_mc.emmc<-emmeans(DIC_mc, ~Sub_region+Year)
         DIC_mc.emmc<-multcomp::cld(DIC_mc.emmc)
         DIC_mc.emmc<-DIC_mc.emmc[order(DIC_mc.emmc$Sub_region),]
  DIC_mc.emmc

Offshore

hist(Trends.offshore$DIC_umol_kg)

shapiro.test(Trends.offshore$DIC_umol_kg)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.offshore$DIC_umol_kg
## W = 0.92737, p-value = 8.011e-13
DIC_of<-lmer(DIC_umol_kg~Year * Sub_region + 
               (1|Month) + (1|SiteID),
               data=Trends.offshore)
  #summary(DIC_of)    
  anova(DIC_of)
  ranova(DIC_of)
  step(DIC_of)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -1695.8 3413.7                         
## (1 | SiteID)          1   10 -1695.8 3411.7   0.00  1          1    
## (1 | Month)           0    9 -1757.9 3533.8 124.11  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value   Pr(>F)   
## Year:Sub_region          1  878.8  292.95     3 370.59  0.8509 0.466791   
## Year                     2  406.7  406.66     1 384.15  1.1825 0.277525   
## Sub_region               0 4526.5 1508.84     3 374.98  4.3971 0.004676 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## DIC_umol_kg ~ Sub_region + (1 | Month)
DIC_of<-lmer(DIC_umol_kg ~ Year + Sub_region + (1 | Month),
             data =Trends.offshore)
  summary(DIC_of)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: DIC_umol_kg ~ Year + Sub_region + (1 | Month)
##    Data: Trends.offshore
## 
## REML criterion at convergence: 3400.6
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -5.8843 -0.4329  0.1397  0.6130  2.4102 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 243.8    15.61   
##  Residual             343.9    18.54   
## Number of obs: 390, groups:  Month, 12
## 
## Fixed effects:
##               Estimate Std. Error        df t value Pr(>|t|)   
## (Intercept)   792.3190  1154.5069  384.1392   0.686  0.49295   
## Year            0.6221     0.5721  384.1451   1.087  0.27753   
## Sub_regionUK   -2.9722     2.9870  373.5600  -0.995  0.32037   
## Sub_regionMK   -9.1133     2.9547  373.5576  -3.084  0.00219 **
## Sub_regionLK   -1.3305     2.8028  373.7602  -0.475  0.63528   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.007  0.006              
## Sub_reginMK -0.007  0.005  0.590       
## Sub_reginLK -0.020  0.019  0.624  0.632
  plot(DIC_of)

  qqnorm(resid(DIC_of))

  acf(resid(DIC_of), main="acf(resid(DIC Offshore))") 

  DIC_of.emmc<-emmeans(DIC_of, ~Sub_region+Year)
         DIC_of.emmc<-multcomp::cld(DIC_of.emmc)
         DIC_of.emmc<-DIC_of.emmc[order(DIC_of.emmc$Sub_region),]
  DIC_of.emmc

Oceanic

hist(Trends.ocean$DIC_umol_kg)

shapiro.test(Trends.ocean$DIC_umol_kg)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.ocean$DIC_umol_kg
## W = 0.98641, p-value = 0.1591
DIC_oc<-lmer(DIC_umol_kg ~ Year * Sub_region + 
               (1 | Month)+ (1|SiteID),
               data=Trends.ocean)
  #summary(DIC_oc)    
  anova(DIC_oc)
  ranova(DIC_oc)
  step(DIC_oc)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                     9 -579.29 1176.6                         
## (1 | SiteID)          1    8 -579.29 1174.6  0.000  1          1    
## (1 | Month)           0    7 -599.53 1213.1 40.494  1  1.972e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value    Pr(>F)    
## Year:Sub_region          1  166.40   83.20     2 129.53  0.5593 0.5730028    
## Sub_region               2  121.96   60.98     2 131.46  0.4125 0.6628785    
## Year                     0 1859.81 1859.81     1 144.81 12.6915 0.0004977 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## DIC_umol_kg ~ Year + (1 | Month)
DIC_oc<-lmer(DIC_umol_kg ~ Year+ (1 | Month), data = Trends.ocean)
  summary(DIC_oc)    
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: DIC_umol_kg ~ Year + (1 | Month)
##    Data: Trends.ocean
## 
## REML criterion at convergence: 1171.9
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.4190 -0.4733  0.1114  0.6111  2.2162 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 125.5    11.20   
##  Residual             146.5    12.11   
## Number of obs: 147, groups:  Month, 12
## 
## Fixed effects:
##               Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept) -2168.1995  1182.8873   144.8121  -1.833 0.068860 .  
## Year            2.0884     0.5862   144.8109   3.563 0.000498 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##      (Intr)
## Year -1.000
  plot(DIC_oc)

  qqnorm(resid(DIC_oc))

  acf(resid(DIC_oc), main="acf(resid(DIC open))")

  DIC_oc.emmc<-emmeans(DIC_oc, ~Year)
         DIC_oc.emmc<-multcomp::cld(DIC_oc.emmc)
         #DIC_oc.emmc<-DIC_oc.emmc[order(DIC_oc.emmc$Sub_region),]
  DIC_oc.emmc

Models summary

DIC_models<-list("Inshore" = DIC_in, 
                   "Mid channel" = DIC_mc, 
                   "Offshore" = DIC_of, 
                   "Ocean" = DIC_oc)
modelsummary(DIC_models, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'DIC model outputs',
             coef_map=factor_order)
DIC model outputs
Inshore Mid channel Offshore Ocean
Year 0.683 −1.571 0.622 2.088***
(2.318) (1.548) (0.572) (0.586)
Intercept 675.945 5217.407+ 792.319 −2168.199+
(4678.187) (3124.726) (1154.507) (1182.887)
Upper Keys −16.463 −8.845 −2.972
(18.597) (8.252) (2.987)
Middle Keys −46.289* −21.745** −9.113**
(18.509) (7.279) (2.955)
Lower Keys −70.752*** −24.605*** −1.330
(18.478) (7.267) (2.803)
Num.Obs. 344 318 390 147
R2 Marg. 0.057 0.027 0.022 0.067
R2 Cond. 0.619 0.468 0.428 0.498
AIC 3925.6 3348.0 3414.6 1179.9
BIC 3956.3 3374.4 3442.4 1191.9
ICC 0.6 0.5 0.4 0.5
RMSE 67.43 44.23 18.17 11.61
+ p
#modelsummary(DIC_models, estimate = "p.value")

dTA-All

Long_plot2<- ggplot(Reef.Trends.data) +
        MyTheme +  
        #scale_shape_manual(values=c(24, 25, 21))+
        #guides(fill=guide_legend(override.aes=list(shape=21)))+
        theme(axis.title.x = element_blank())

## 
##  Shapiro-Wilk normality test
## 
## data:  Reef.Trends.data$dTA_MY
## W = 0.82636, p-value < 2.2e-16

Inshore

# Inshore dTA
hist(Trends.inshore$dTA_MY)

shapiro.test(Trends.inshore$dTA_MY)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.inshore$dTA_MY
## W = 0.97537, p-value = 1.479e-05
dTA_in<-lmer(dTA_MY ~ Year * Sub_region + (1|Month)+
                                  #(1|Zone)+             
                                  (1|SiteID),
             data=Trends.inshore)
  #summary(dTA_in)    
  anova(dTA_in)
  ranova(dTA_in)
  step(dTA_in)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC     LRT Df Pr(>Chisq)    
## <none>                    11 -1907.7 3837.3                          
## (1 | SiteID)          1   10 -1908.4 3836.8   1.494  1     0.2215    
## (1 | Month)           0    9 -1988.5 3995.0 160.211  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value Pr(>F)    
## Year:Sub_region          1  24316    8105     3 320.99  1.7756 0.1517    
## Year                     2    514     514     1 334.99  0.1118 0.7383    
## Sub_region               0 521831  173944     3 325.00 37.9152 <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## dTA_MY ~ Sub_region + (1 | Month)
dTA_in<-lmer(dTA_MY ~ Sub_region + (1 | Month),
             data=Trends.inshore)
  summary(dTA_in)    
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: dTA_MY ~ Sub_region + (1 | Month)
##    Data: Trends.inshore
## 
## REML criterion at convergence: 3840.1
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.5210 -0.5933  0.0214  0.5820  3.2516 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 4316     65.70   
##  Residual             4588     67.73   
## Number of obs: 340, groups:  Month, 12
## 
## Fixed effects:
##              Estimate Std. Error      df t value Pr(>|t|)    
## (Intercept)    -4.420     20.788  14.432  -0.213  0.83458    
## Sub_regionUK    2.995     11.181 324.943   0.268  0.78898    
## Sub_regionMK  -34.377     10.994 324.943  -3.127  0.00193 ** 
## Sub_regionLK  -92.729     10.874 325.016  -8.527 5.74e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Sb_rUK Sb_rMK
## Sub_reginUK -0.305              
## Sub_reginMK -0.311  0.575       
## Sub_reginLK -0.314  0.580  0.594
  plot(dTA_in)

  qqnorm(resid(dTA_in))

  acf(resid(dTA_in), main="acf(resid(dTA Inshore))")

  dTA_in.emmc<-emmeans(dTA_in, ~Sub_region)
         dTA_in.emmc<-multcomp::cld(dTA_in.emmc)
         dTA_in.emmc<-dTA_in.emmc[order(dTA_in.emmc$Sub_region),]
  dTA_in.emmc

Mid channel

hist(Trends.midchanel$dTA_MY)

shapiro.test(Trends.midchanel$dTA_MY)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.midchanel$dTA_MY
## W = 0.84625, p-value < 2.2e-16
dTA_mc<-lmer(dTA_MY~Year * Sub_region + (1|Month) + 
                                  #(1|Zone)+             
                                  (1|SiteID),
             data=Trends.midchanel)
  #summary(dTA_mc)    
  anova(dTA_mc)
  ranova(dTA_mc)
  step(dTA_mc)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -1634.9 3291.8                         
## (1 | Month)           0   10 -1675.4 3370.9 81.063  1    < 2e-16 ***
## (1 | SiteID)          0   10 -1636.5 3293.1  3.278  1    0.07021 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value  Pr(>F)  
## Year:Sub_region          1  6569.9  2190.0     3 292.08  1.2103 0.30618  
## Year                     2  3291.7  3291.7     1 303.51  1.8147 0.17895  
## Sub_region               0 26984.9  8995.0     3   6.28  4.9261 0.04385 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## dTA_MY ~ Sub_region + (1 | Month) + (1 | SiteID)
dTA_mc<-lmer(dTA_MY ~ (1 | Month) + (1|SiteID), 
             data = Trends.midchanel)
  summary(dTA_mc) 
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: dTA_MY ~ (1 | Month) + (1 | SiteID)
##    Data: Trends.midchanel
## 
## REML criterion at convergence: 3319.3
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.9404 -0.4288  0.1101  0.5806  3.3889 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept)  883.6   29.73   
##  SiteID   (Intercept)  256.2   16.01   
##  Residual             1826.3   42.74   
## Number of obs: 317, groups:  Month, 12; SiteID, 10
## 
## Fixed effects:
##             Estimate Std. Error     df t value Pr(>|t|)
## (Intercept)   -17.91      10.28  15.93  -1.743    0.101
  plot(dTA_mc)

  qqnorm(resid(dTA_mc))

  acf(resid(dTA_mc), main="acf(resid(dTA Mid Channel))") 

Offshore

hist(Trends.offshore$dTA_MY)

shapiro.test(Trends.offshore$dTA_MY)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.offshore$dTA_MY
## W = 0.82187, p-value < 2.2e-16
dTA_of<-lmer(dTA_MY~Year * Sub_region + 
               (1|Month) + (1|SiteID),
               data=Trends.offshore)
  #summary(dTA_of)    
  anova(dTA_of)
  ranova(dTA_of)
  step(dTA_of)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -1614.0 3249.9                         
## (1 | SiteID)          1   10 -1614.0 3247.9  0.000  1          1    
## (1 | Month)           0    9 -1638.7 3295.3 49.396  1  2.091e-12 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value  Pr(>F)  
## Year:Sub_region          1  201.07   67.02     3 366.30  0.2673 0.84897  
## Year                     0 1160.22 1160.22     1 350.84  4.6547 0.03165 *
## Sub_region               0 2796.99  932.33     3 369.62  3.7404 0.01136 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## dTA_MY ~ Year + Sub_region + (1 | Month)
dTA_of<-lmer(dTA_MY ~ Sub_region + (1 | Month), 
             data =Trends.offshore)
  summary(dTA_of)    
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: dTA_MY ~ Sub_region + (1 | Month)
##    Data: Trends.offshore
## 
## REML criterion at convergence: 3238.8
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -5.6298 -0.3162  0.0951  0.5352  3.7473 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept)  56.29    7.503  
##  Residual             253.19   15.912  
## Number of obs: 386, groups:  Month, 12
## 
## Fixed effects:
##              Estimate Std. Error       df t value Pr(>|t|)  
## (Intercept)   -1.8949     2.9537  27.7282  -0.642   0.5264  
## Sub_regionUK   0.6773     2.5912 370.9652   0.261   0.7939  
## Sub_regionMK  -5.7043     2.5691 370.9841  -2.220   0.0270 *
## Sub_regionLK  -4.4724     2.4279 371.6955  -1.842   0.0663 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Sb_rUK Sb_rMK
## Sub_reginUK -0.516              
## Sub_reginMK -0.523  0.594       
## Sub_reginLK -0.554  0.629  0.637
  plot(dTA_of)

  qqnorm(resid(dTA_of))

  acf(resid(dTA_of), main="acf(resid(dTA Offshore))") 

  dTA_of.emmc<-emmeans(dTA_of, ~Sub_region)
         dTA_of.emmc<-multcomp::cld(dTA_of.emmc)
         dTA_of.emmc<-dTA_of.emmc[order(dTA_of.emmc$Sub_region),]
  dTA_of.emmc

Models summary

dTA_models<-list("Inshore" = dTA_in, 
                   "Mid channel" = dTA_mc, 
                   "Offshore" = dTA_of)
modelsummary(dTA_models, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'dTA model outputs',
             coef_map=factor_order)
dTA model outputs
Inshore Mid channel Offshore
Intercept −4.420 −17.914+ −1.895
(20.788) (10.280) (2.954)
Upper Keys 2.995 0.677
(11.181) (2.591)
Middle Keys −34.377** −5.704*
(10.994) (2.569)
Lower Keys −92.729*** −4.472+
(10.874) (2.428)
Num.Obs. 340 317 386
R2 Marg. 0.149 0.000 0.023
R2 Cond. 0.562 0.384 0.201
AIC 3852.1 3327.3 3250.8
BIC 3875.1 3342.3 3274.6
ICC 0.5 0.4 0.2
RMSE 66.27 41.47 15.63
+ p
#modelsummary(dTA_models, estimate = "p.value")

dDIC-All

## 
##  Shapiro-Wilk normality test
## 
## data:  Reef.Trends.data$dDIC_MY
## W = 0.87871, p-value < 2.2e-16

Inshore

# Inshore dDIC
hist(Trends.inshore$dDIC_MY)

shapiro.test(Trends.inshore$dDIC_MY)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.inshore$dDIC_MY
## W = 0.99469, p-value = 0.2936
dDIC_in<-lmer(dDIC_MY~Year * Sub_region + (1|Month)+
                                  #(1|Zone)+             
                                  (1|SiteID), 
              data=Trends.inshore)
  #summary(dDIC_in)    
  anova(dDIC_in)
  ranova(dDIC_in)
  step(dDIC_in)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC     LRT Df Pr(>Chisq)    
## <none>                    11 -1904.2 3830.5                          
## (1 | Month)           0   10 -2019.6 4059.1 230.620  1    < 2e-16 ***
## (1 | SiteID)          0   10 -1907.0 3834.1   5.592  1    0.01804 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value  Pr(>F)  
## Year:Sub_region          1  25533  8511.1     3 312.67  1.8460 0.13874  
## Year                     2   1925  1925.4     1 325.59  0.4142 0.52028  
## Sub_region               0  88730 29576.7     3   7.24  6.3731 0.01943 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## dDIC_MY ~ Sub_region + (1 | Month) + (1 | SiteID)
dDIC_in<-lmer(dDIC_MY ~ Sub_region + (1 | Month)+ (1 | SiteID),
              data=Trends.inshore)
  summary(dDIC_in)    
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: dDIC_MY ~ Sub_region + (1 | Month) + (1 | SiteID)
##    Data: Trends.inshore
## 
## REML criterion at convergence: 3832.4
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.3028 -0.6819  0.0077  0.6656  2.8679 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 6311.1   79.44   
##  SiteID   (Intercept)  269.4   16.41   
##  Residual             4640.9   68.12   
## Number of obs: 338, groups:  Month, 12; SiteID, 11
## 
## Fixed effects:
##              Estimate Std. Error      df t value Pr(>|t|)   
## (Intercept)     9.859     27.092  16.462   0.364  0.72056   
## Sub_regionUK  -16.203     18.739   7.264  -0.865  0.41486   
## Sub_regionMK  -46.709     18.623   7.089  -2.508  0.04009 * 
## Sub_regionLK  -72.041     18.574   7.014  -3.879  0.00604 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Sb_rUK Sb_rMK
## Sub_reginUK -0.407              
## Sub_reginMK -0.410  0.591       
## Sub_reginLK -0.410  0.592  0.597
  plot(dDIC_in)

  qqnorm(resid(dDIC_in))

  acf(resid(dDIC_in), main="acf(resid(dDIC Inshore))") 

  dDIC_in.emmc<-emmeans(dDIC_in, ~Sub_region)
         dDIC_in.emmc<-multcomp::cld(dDIC_in.emmc)
         dDIC_in.emmc<-dDIC_in.emmc[order(dDIC_in.emmc$Sub_region),]
  dDIC_in.emmc

Mid channel

hist(Trends.midchanel$dDIC_MY)

shapiro.test(Trends.midchanel$dDIC_MY)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.midchanel$dDIC_MY
## W = 0.90543, p-value = 3.815e-13
dDIC_mc<-lmer(dDIC_MY~Year * Sub_region + (1|Month) + 
                                  #(1|Zone)+             
                                  (1|SiteID), data=Trends.midchanel)
  #summary(dDIC_mc)    
  anova(dDIC_mc)
  ranova(dDIC_mc)
  step(dDIC_mc)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -1630.0 3282.0                         
## (1 | SiteID)          1   10 -1630.9 3281.9   1.85  1     0.1738    
## (1 | Month)           0    9 -1689.2 3396.3 116.45  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value   Pr(>F)   
## Year:Sub_region          1   9222  3074.2     3 296.02  1.6147 0.186019   
## Year                     0  11873 11873.1     1 309.30  6.1955 0.013333 * 
## Sub_region               0  31740 10580.0     3 299.10  5.5207 0.001058 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## dDIC_MY ~ Year + Sub_region + (1 | Month)
dDIC_mc<-lmer(dDIC_MY ~ Sub_region + (1 | Month),
              data = Trends.midchanel)
  summary(dDIC_mc) 
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: dDIC_MY ~ Sub_region + (1 | Month)
##    Data: Trends.midchanel
## 
## REML criterion at convergence: 3287.5
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.3642 -0.4770  0.0429  0.5740  3.8569 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 1200     34.63   
##  Residual             1956     44.22   
## Number of obs: 315, groups:  Month, 12
## 
## Fixed effects:
##              Estimate Std. Error      df t value Pr(>|t|)    
## (Intercept)     2.059     11.481  16.715   0.179 0.859861    
## Sub_regionUK   -9.921      8.097 300.141  -1.225 0.221439    
## Sub_regionMK  -22.716      7.179 300.116  -3.164 0.001715 ** 
## Sub_regionLK  -25.558      7.148 300.219  -3.576 0.000407 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Sb_rUK Sb_rMK
## Sub_reginUK -0.334              
## Sub_reginMK -0.379  0.534       
## Sub_reginLK -0.380  0.537  0.608
  plot(dDIC_mc) 

  qqnorm(resid(dDIC_mc))

  acf(resid(dDIC_mc), main="acf(resid(dDIC Mid Channel))") 

  dDIC_mc.emmc<-emmeans(dDIC_mc, ~Sub_region)
         dDIC_mc.emmc<-multcomp::cld(dDIC_mc.emmc)
         dDIC_mc.emmc<-dDIC_mc.emmc[order(dDIC_mc.emmc$Sub_region),]
  dDIC_mc.emmc

Offshore

hist(Trends.offshore$dDIC_MY)

shapiro.test(Trends.offshore$dDIC_MY)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.offshore$dDIC_MY
## W = 0.78582, p-value < 2.2e-16
dDIC_of<-lmer(dDIC_MY~Year * Sub_region + 
               (1|Month) + (1|SiteID),
               data=Trends.offshore)
  #summary(dDIC_of)    
  anova(dDIC_of)
  ranova(dDIC_of)
  step(dDIC_of)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -1603.4 3228.9                         
## (1 | SiteID)          1   10 -1603.4 3226.9  0.000  1          1    
## (1 | Month)           0    9 -1616.4 3250.8 25.897  1  3.602e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value   Pr(>F)   
## Year:Sub_region          1  974.6  324.87     3 366.36  1.3149 0.269227   
## Year                     0 2077.2 2077.25     1 280.89  8.3858 0.004079 **
## Sub_region               0 3751.7 1250.57     3 369.77  5.0485 0.001937 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## dDIC_MY ~ Year + Sub_region + (1 | Month)
dDIC_of<-lmer(dDIC_MY ~ Year+ Sub_region + (1 | Month), 
              data =Trends.offshore)
  summary(dDIC_of)    
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: dDIC_MY ~ Year + Sub_region + (1 | Month)
##    Data: Trends.offshore
## 
## REML criterion at convergence: 3216.2
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -6.2028 -0.3388  0.1296  0.5453  3.7043 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept)  33.24    5.765  
##  Residual             247.71   15.739  
## Number of obs: 385, groups:  Month, 12
## 
## Fixed effects:
##               Estimate Std. Error        df t value Pr(>|t|)    
## (Intercept)  2687.6949   927.6272  280.8380   2.897 0.004059 ** 
## Year           -1.3312     0.4597  280.8893  -2.896 0.004079 ** 
## Sub_regionUK   -2.7375     2.5630  369.2943  -1.068 0.286173    
## Sub_regionMK   -8.6035     2.5411  369.3350  -3.386 0.000786 ***
## Sub_regionLK   -1.7183     2.4011  370.0752  -0.716 0.474676    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.008  0.006              
## Sub_reginMK -0.007  0.005  0.594       
## Sub_reginLK -0.019  0.017  0.630  0.636
  plot(dDIC_of)

  qqnorm(resid(dDIC_of))

  acf(resid(dDIC_of), main="acf(resid(dDIC Offshore))") 

  dDIC_of.emmc<-emmeans(dDIC_of, ~Sub_region+Year)
         dDIC_of.emmc<-multcomp::cld(dDIC_of.emmc)
         dDIC_of.emmc<-dDIC_of.emmc[order(dDIC_of.emmc$Sub_region),]
  dDIC_of.emmc

Models summary

dDIC_models<-list("Inshore" = dDIC_in, 
                   "Mid channel" = dDIC_mc, 
                   "Offshore" = dDIC_of)
modelsummary(dDIC_models, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'dDIC model outputs',
             coef_map=factor_order)
dDIC model outputs
Inshore Mid channel Offshore
Year −1.331**
(0.460)
Intercept 9.859 2.059 2687.695**
(27.092) (11.481) (927.627)
Upper Keys −16.203 −9.921 −2.738
(18.739) (8.097) (2.563)
Middle Keys −46.709* −22.716** −8.603***
(18.623) (7.179) (2.541)
Lower Keys −72.041*** −25.558*** −1.718
(18.574) (7.148) (2.401)
Num.Obs. 338 315 385
R2 Marg. 0.063 0.031 0.059
R2 Cond. 0.612 0.399 0.171
AIC 3846.4 3299.5 3230.2
BIC 3873.2 3322.1 3257.9
ICC 0.6 0.4 0.1
RMSE 66.16 43.21 15.46
+ p
#modelsummary(dDIC_models, estimate = "p.value")

7. PCA

#str(Month_Stats)
PCA_variables<-c("DIC_mean", "TA_mean", "pCO2_mean", "Ara_mean",
              "pH_mean", "Tem_mean","Sal_mean", "Season",
              "Zone", "Sub_region", "Month2")

PCA.data<-select(Month_Stats, PCA_variables)

Name<-paste(Month_Stats$Zone, Month_Stats$Sub_region, 
            Month_Stats$Month, sep = "_")
rownames(PCA.data) <- (Name)
PCA_var.names<-c("DIC", "TA", "pCO2", "Ara",
              "pH", "Temp","Sal", "Season",
              "Zone", "Sub_region", "Month")
colnames(PCA.data) <- (PCA_var.names)
#ggpairs(PCA.data)
head(PCA.data)
library(vegan)
#library(autoplot)
library(ggfortify)

CC.rda1 <- rda(PCA.data[, -(6:11)], scale=TRUE)
CC.rda2 <- prcomp(PCA.data[, -(6:11)], scale=TRUE)
summary(CC.rda1)
## 
## Call:
## rda(X = PCA.data[, -(6:11)], scale = TRUE) 
## 
## Partitioning of correlations:
##               Inertia Proportion
## Total               5          1
## Unconstrained       5          1
## 
## Eigenvalues, and their contribution to the correlations 
## 
## Importance of components:
##                         PC1    PC2     PC3      PC4       PC5
## Eigenvalue            2.525 1.9755 0.49029 0.007685 0.0012795
## Proportion Explained  0.505 0.3951 0.09806 0.001537 0.0002559
## Cumulative Proportion 0.505 0.9001 0.99821 0.999744 1.0000000
## 
## Scaling 2 for species and site scores
## * Species are scaled proportional to eigenvalues
## * Sites are unscaled: weighted dispersion equal on all dimensions
## * General scaling constant of scores:  5.469602 
## 
## 
## Species scores
## 
##          PC1     PC2      PC3       PC4       PC5
## DIC  -0.1277  2.4406 -0.08088 -0.009083 -0.061307
## TA    0.9923  2.1598 -0.57496 -0.013337  0.056949
## pCO2 -2.3514  0.1789 -0.63231  0.150261  0.005565
## Ara   1.7375 -1.0641 -1.35334  0.003904 -0.024707
## pH    2.3581  0.1857  0.60424  0.152077 -0.003531
## 
## 
## Site scores (weighted sums of species scores)
## 
##                          PC1       PC2       PC3        PC4        PC5
## Inshore_BB_Jan     -0.101692  0.764688  0.449665 -0.0869779 -1.467e-01
## Inshore_BB_Feb      0.411329  0.473426  0.348590  0.2083096 -2.794e-01
## Inshore_BB_Mar      0.490212  0.347346  0.026759  0.2805043 -5.204e-02
## Inshore_BB_Apr      0.736874 -0.492056  0.076297  0.5869598  1.949e-01
## Inshore_BB_May      0.662231 -0.367179 -0.164388  0.4705262  5.305e-02
## Inshore_BB_Jun     -0.015294 -0.859711  0.493279 -0.3711948 -1.913e-01
## Inshore_BB_Jul     -0.512410 -0.337088 -0.162303 -0.1745752  4.554e-01
## Inshore_BB_Aug     -0.509657 -0.223719 -0.492129  0.6682418  2.631e-01
## Inshore_BB_Sep     -1.120955  0.327362 -0.325952  1.9065707 -4.660e-02
## Inshore_BB_Oct     -1.140928  0.678314 -0.352180  1.6677999  2.892e-01
## Inshore_BB_Nov     -0.399655  0.668559 -0.038580  0.1471773  2.220e-01
## Inshore_BB_Dec     -0.139179  0.648269  0.371045 -0.0825210 -1.677e-01
## Inshore_UK_Jan      0.103639  0.908575  0.328148  0.1084290 -3.095e-02
## Inshore_UK_Feb      0.685704  0.165954  0.327089  0.6422276 -2.137e-01
## Inshore_UK_Mar      0.613208  0.190233 -0.016753  0.3949519  3.777e-01
## Inshore_UK_Apr      1.256829 -1.048020 -0.084817  1.9471954  3.566e-01
## Inshore_UK_May      1.029433 -0.896480 -0.128602  1.0829165  4.432e-01
## Inshore_UK_Jun      0.306790 -0.506137 -0.156907 -0.2447972  3.406e-02
## Inshore_UK_Jul     -0.215208 -0.283626 -0.464902 -0.1609288  1.689e-01
## Inshore_UK_Aug      0.145470 -0.371549 -0.804241 -0.3155772  7.423e-02
## Inshore_UK_Sep     -0.946748 -0.098190 -0.427248  1.0481384 -3.515e-02
## Inshore_UK_Oct     -1.082722  0.478424 -0.300201  1.6129185  2.203e-01
## Inshore_UK_Nov     -0.812724  1.027718 -0.216739  1.2106072  8.413e-01
## Inshore_UK_Dec     -0.172923  0.943165  0.105962  0.0764009  3.233e-01
## Inshore_MK_Jan     -0.086807  0.956835  0.253283 -0.0444325  1.920e-01
## Inshore_MK_Feb      0.807929  0.499034  0.006600  0.9752010 -1.052e+00
## Inshore_MK_Mar      0.491007  0.248469 -0.043740  0.1852552  4.994e-01
## Inshore_MK_Apr      0.967710 -0.664034 -0.077765  1.1067829  3.839e-01
## Inshore_MK_May      0.982311 -1.008389  0.002033  1.1519032  5.411e-01
## Inshore_MK_Jun      0.182232 -1.065783  0.317326 -0.0755431 -1.900e-02
## Inshore_MK_Jul     -0.691859 -1.148737  0.627582 -0.4850169  5.502e-01
## Inshore_MK_Aug     -0.312859 -0.914083  0.286588 -0.5818578  5.898e-02
## Inshore_MK_Sep     -0.890765 -0.922617  0.415566 -0.1534626  3.959e-01
## Inshore_MK_Oct     -0.575069  0.104661 -0.086529  0.6346904 -5.686e-01
## Inshore_MK_Nov     -0.288229  0.145157  0.189211 -0.1743009  2.256e-01
## Inshore_MK_Dec     -0.085250  0.867926  0.215879  0.0374703 -7.386e-03
## Inshore_LK_Jan     -0.590510  0.586403  0.972785 -0.0952322  2.529e-01
## Inshore_LK_Feb      0.256754  0.554422  0.367560  0.1525029 -4.758e-01
## Inshore_LK_Mar      0.443808  0.051851  0.256576  0.3682254  1.555e-01
## Inshore_LK_Apr      0.399019 -0.759818  0.588020  0.2925842 -3.487e-01
## Inshore_LK_May      0.242058 -1.253166  1.122755 -0.0242360 -9.287e-02
## Inshore_LK_Jun     -0.289364 -0.925207  0.621510 -0.3183745  1.259e-01
## Inshore_LK_Jul     -1.178564 -0.905052  0.788844  0.0603697  5.616e-01
## Inshore_LK_Aug     -1.064509 -1.114304  0.822035  0.3532532 -2.031e+00
## Inshore_LK_Sep     -1.319835 -0.839383  0.681681  0.6565191  1.676e-01
## Inshore_LK_Oct     -0.984068 -0.316540  0.678260  0.4606837 -2.698e-01
## Inshore_LK_Nov     -0.907926  0.267668  0.461256  0.1593844  9.032e-01
## Inshore_LK_Dec     -0.336361  0.163126  1.010217 -0.2489135 -2.481e-01
## Mid channel_BB_Jan  0.072858  0.277731  0.414876 -0.1977492 -9.959e-03
## Mid channel_BB_Feb  0.165595  0.288367  0.495426 -0.0970749 -1.843e-01
## Mid channel_BB_Mar  0.294564  0.205877  0.261025 -0.0868500  1.849e-01
## Mid channel_BB_Apr  0.349075 -0.053342  0.092296 -0.0322772  1.651e-01
## Mid channel_BB_May  0.328483  0.049237 -0.142553 -0.1319071  1.918e-01
## Mid channel_BB_Jun  0.029804 -0.167600 -0.151190 -0.2618361 -1.679e-01
## Mid channel_BB_Jul -0.203670 -0.003389 -0.530774 -0.1827288  1.985e-01
## Mid channel_BB_Aug -0.271202 -0.110264 -0.569853 -0.1970345  2.866e-01
## Mid channel_BB_Sep -0.548567  0.030415 -0.240530  0.2790886 -4.110e-01
## Mid channel_BB_Oct -0.360853  0.181900 -0.299527  0.1125300 -2.588e-01
## Mid channel_BB_Nov -0.099909  0.197236  0.035237 -0.1526986  2.212e-01
## Mid channel_BB_Dec -0.018258  0.369561  0.285468 -0.1815158  8.856e-03
## Mid channel_UK_Jan  0.219630  0.343525  0.329522 -0.0589944 -1.232e-01
## Mid channel_UK_Feb  0.352206  0.168912  0.517120  0.1301548 -3.850e-01
## Mid channel_UK_Mar  0.446768  0.001498  0.234928  0.1912685  1.164e-01
## Mid channel_UK_Apr  0.605343 -0.163994 -0.141341  0.3796071  1.577e-01
## Mid channel_UK_May  0.690927 -0.138947 -0.367168  0.4295415  3.816e-01
## Mid channel_UK_Jun  0.122324 -0.078102 -0.409761 -0.2671719  1.735e-01
## Mid channel_UK_Jul -0.167275 -0.083122 -0.534784 -0.1879445 -4.335e-05
## Mid channel_UK_Aug  0.111801  0.015420 -0.943865 -0.2843416  1.953e-01
## Mid channel_UK_Sep -0.108159 -0.191652 -0.670154 -0.1057227 -6.516e-01
## Mid channel_UK_Oct -0.344193  0.137987 -0.360602  0.1458208 -4.654e-01
## Mid channel_UK_Nov -0.206508  0.049982  0.188381 -0.1867746 -1.544e-01
## Mid channel_UK_Dec  0.035982  0.353246  0.262658 -0.2006087  9.268e-02
## Mid channel_MK_Jan  0.006826  0.623043  0.197904 -0.1301287  2.063e-01
## Mid channel_MK_Feb  0.377761  0.224931  0.427795  0.1525932 -3.160e-01
## Mid channel_MK_Mar  0.449739  0.171732  0.155446  0.2420828  3.164e-01
## Mid channel_MK_Apr  0.599260 -0.120431 -0.161504  0.2063767  2.403e-01
## Mid channel_MK_May  0.596198 -0.467539 -0.096949  0.3595340  3.313e-01
## Mid channel_MK_Jun  0.024454 -0.573247  0.026251 -0.3622452 -4.745e-02
## Mid channel_MK_Jul -0.371343 -0.598889 -0.053716 -0.4253270  1.448e-01
## Mid channel_MK_Aug -0.021205 -0.423305 -0.440860 -0.4178271 -3.502e-02
## Mid channel_MK_Sep -0.666429 -0.518907  0.074397 -0.0390396 -2.984e-01
## Mid channel_MK_Oct -0.167531  0.097697 -0.377172  0.0179380 -5.224e-01
## Mid channel_MK_Nov -0.074390  0.024545  0.087943 -0.2198889 -7.096e-02
## Mid channel_MK_Dec -0.035669  0.478599  0.301253 -0.0983641  2.443e-02
## Mid channel_LK_Jan -0.381032  0.492188  0.692426 -0.1012309 -4.719e-02
## Mid channel_LK_Feb  0.279374  0.499146  0.287640  0.1167638 -2.157e-01
## Mid channel_LK_Mar  0.215759  0.256958  0.195080 -0.0739025  9.371e-02
## Mid channel_LK_Apr  0.147505 -0.143263  0.159186  0.2862757  1.467e-01
## Mid channel_LK_May  0.223506 -0.672981  0.620235 -0.1874764  8.517e-02
## Mid channel_LK_Jun -0.077875 -0.297636 -0.027333 -0.3132011  1.342e-01
## Mid channel_LK_Jul -0.403600 -0.286449 -0.270734 -0.1919318  2.987e-01
## Mid channel_LK_Aug -0.388018 -0.540975 -0.018485 -0.3563497  2.447e+00
## Mid channel_LK_Sep -0.609209 -0.614102  0.180602 -0.1288225 -4.566e-01
## Mid channel_LK_Oct -0.282524  0.010178 -0.213631 -0.0391452 -3.898e-01
## Mid channel_LK_Nov -0.216250  0.056487  0.123276 -0.1844727  1.566e-01
## Mid channel_LK_Dec  0.007958  0.213739  0.390748 -0.1809511 -5.000e-02
## Offshore_BB_Jan     0.117931  0.188697  0.258795 -0.1384178 -2.301e-01
## Offshore_BB_Feb     0.266654  0.122053  0.522797  0.0005333 -2.691e-01
## Offshore_BB_Mar     0.277813  0.156643  0.259581 -0.0980915  1.912e-01
## Offshore_BB_Apr     0.074246  0.170608  0.090668 -0.2357099  2.227e-01
## Offshore_BB_May     0.184531  0.112029 -0.082850 -0.1769311  5.816e-02
## Offshore_BB_Jun    -0.159521  0.072722 -0.243451 -0.1852854  2.180e-01
## Offshore_BB_Jul    -0.105547  0.013917 -0.589505 -0.1635631 -5.489e-02
## Offshore_BB_Aug    -0.400411 -0.012712 -0.541277 -0.0319487  4.332e-01
## Offshore_BB_Sep    -0.206036 -0.048595 -0.575752  0.2423331 -6.258e-01
## Offshore_BB_Oct    -0.091815  0.020853 -0.376238 -0.0736775 -5.454e-01
## Offshore_BB_Nov     0.104135  0.044067 -0.082375 -0.2587373  2.264e-01
## Offshore_BB_Dec     0.042602  0.211438  0.192773 -0.1650565 -8.193e-03
## Offshore_UK_Jan     0.147666  0.199716  0.272339 -0.1819025  1.643e-02
## Offshore_UK_Feb     0.249181  0.205046  0.587788  0.0346223 -4.138e-01
## Offshore_UK_Mar     0.232532  0.168046  0.230386 -0.1603731  1.991e-01
## Offshore_UK_Apr     0.095790  0.148234  0.109856 -0.2034063  1.614e-01
## Offshore_UK_May     0.142516  0.168077 -0.133043 -0.2349351  3.158e-01
## Offshore_UK_Jun    -0.062876  0.035370 -0.298632 -0.2678513  2.615e-01
## Offshore_UK_Jul    -0.154888 -0.072926 -0.544596 -0.2102515  7.839e-02
## Offshore_UK_Aug     0.033719  0.011813 -0.834714 -0.2830393  2.406e-01
## Offshore_UK_Sep    -0.030449 -0.189680 -0.674330 -0.1217400 -6.031e-01
## Offshore_UK_Oct     0.007278  0.011817 -0.387918 -0.0976288 -6.068e-01
## Offshore_UK_Nov    -0.038626 -0.015899  0.034318 -0.2891813 -1.899e-02
## Offshore_UK_Dec     0.026565  0.272532  0.157154 -0.1832805  9.688e-02
## Offshore_MK_Jan     0.055341  0.250933  0.307363 -0.2231282  3.783e-02
## Offshore_MK_Feb     0.262676  0.225349  0.643125  0.0653042 -4.477e-01
## Offshore_MK_Mar     0.202719  0.197666  0.237768 -0.1782254  2.423e-01
## Offshore_MK_Apr     0.215767  0.089472  0.065777 -0.1581338  1.762e-01
## Offshore_MK_May     0.118301  0.115507 -0.095814 -0.2116825  2.898e-01
## Offshore_MK_Jun     0.093702 -0.149516 -0.229294 -0.2879109  3.897e-02
## Offshore_MK_Jul    -0.198118 -0.235912 -0.346218 -0.2364678 -9.018e-02
## Offshore_MK_Aug     0.016318 -0.075413 -0.695662 -0.2806353  6.241e-02
## Offshore_MK_Sep    -0.118657 -0.327469 -0.359498 -0.2140151 -6.160e-01
## Offshore_MK_Oct    -0.021657  0.030952 -0.425119 -0.0617342 -6.243e-01
## Offshore_MK_Nov     0.174361 -0.040168 -0.125784 -0.2315399 -1.994e-02
## Offshore_MK_Dec     0.082480  0.164161  0.248462 -0.1367257 -1.002e-01
## Offshore_LK_Jan     0.049944  0.294368  0.407952 -0.2244982  5.327e-02
## Offshore_LK_Feb     0.161692  0.288950  0.711888  0.0237256 -4.726e-01
## Offshore_LK_Mar     0.153579  0.138987  0.190385 -0.2025989  2.656e-01
## Offshore_LK_Apr    -0.039603  0.124644  0.185897 -0.1915875  2.674e-01
## Offshore_LK_May     0.013459  0.116165  0.080236 -0.3129287  3.317e-01
## Offshore_LK_Jun    -0.095265  0.005308 -0.238342 -0.2873527  2.462e-01
## Offshore_LK_Jul    -0.274100  0.027011 -0.539493 -0.1069307  2.720e-01
## Offshore_LK_Aug    -0.191214  0.041170 -0.616743 -0.1604437  4.367e-01
## Offshore_LK_Sep    -0.101153 -0.220469 -0.348600 -0.1179020 -7.505e-01
## Offshore_LK_Oct    -0.098867  0.042590 -0.318652 -0.1275626 -3.529e-01
## Offshore_LK_Nov     0.025507  0.030756 -0.036429 -0.2910472  1.905e-01
## Offshore_LK_Dec     0.117070  0.148438  0.206297 -0.0794536 -1.970e-01
## Oceanic_UK_Jan      0.122084  0.128552  0.151598 -0.1991850 -4.899e-02
## Oceanic_UK_Feb      0.267501  0.200894  0.580924  0.0174188 -2.136e-01
## Oceanic_UK_Mar      0.205907  0.061896  0.279773 -0.1556273  3.354e-03
## Oceanic_UK_Apr      0.235957  0.086173  0.193152 -0.1105785 -5.070e-02
## Oceanic_UK_May      0.308602  0.120778 -0.120869 -0.1807755  3.159e-01
## Oceanic_UK_Jun      0.086370  0.043022 -0.372061 -0.2684308  2.078e-01
## Oceanic_UK_Jul     -0.029891 -0.079757 -0.588155 -0.2230675 -1.222e-01
## Oceanic_UK_Aug      0.131193  0.140414 -0.941440 -0.2782154  3.825e-01
## Oceanic_UK_Sep      0.140817 -0.223827 -0.634653 -0.0901625 -1.076e+00
## Oceanic_UK_Oct     -0.053356  0.001929 -0.452062 -0.0815494 -5.247e-01
## Oceanic_UK_Nov      0.041568 -0.038498  0.050565 -0.2093171 -3.668e-01
## Oceanic_UK_Dec      0.118066  0.193551  0.068670 -0.1596925  1.308e-01
## Oceanic_MK_Jan      0.127618  0.189886  0.254430 -0.1846258 -2.328e-02
## Oceanic_MK_Feb      0.317716  0.130493  0.486674  0.0556385 -2.853e-01
## Oceanic_MK_Mar      0.123864  0.107886  0.180313 -0.2493826  1.761e-01
## Oceanic_MK_Apr      0.016379  0.170126  0.082657 -0.2350953  2.830e-01
## Oceanic_MK_May      0.034261  0.212923 -0.102523 -0.2294717  3.027e-01
## Oceanic_MK_Jun      0.055220  0.034612 -0.380733 -0.2781171  2.850e-01
## Oceanic_MK_Jul     -0.039370 -0.058907 -0.581487 -0.1872127 -1.817e-01
## Oceanic_MK_Aug      0.005774  0.053505 -0.761004 -0.2179016  5.120e-02
## Oceanic_MK_Sep      0.143325 -0.134244 -0.638105 -0.1346925 -7.852e-01
## Oceanic_MK_Oct     -0.035298  0.072413 -0.515501 -0.0967100 -3.312e-01
## Oceanic_MK_Nov      0.186024 -0.008573 -0.200512 -0.2785958  2.492e-01
## Oceanic_MK_Dec      0.065866  0.134077  0.226933 -0.1457790 -1.057e-01
## Oceanic_LK_Jan      0.107180  0.219970  0.316379 -0.2213347  1.135e-01
## Oceanic_LK_Feb      0.311173  0.212812  0.526674  0.0657674 -1.921e-01
## Oceanic_LK_Mar      0.139360  0.079101  0.145613 -0.2284421  1.434e-01
## Oceanic_LK_Apr     -0.021097  0.138446  0.142587 -0.2539904  1.675e-01
## Oceanic_LK_May      0.032263  0.184316 -0.006528 -0.2868972  3.129e-01
## Oceanic_LK_Jun      0.010050  0.064792 -0.347627 -0.2520383  2.632e-01
## Oceanic_LK_Jul     -0.091297 -0.048126 -0.461958 -0.1395289 -4.279e-01
## Oceanic_LK_Aug     -0.083617  0.068552 -0.705873 -0.1619561 -2.814e-01
## Oceanic_LK_Sep      0.195644 -0.195147 -0.563994 -0.0508689 -1.127e+00
## Oceanic_LK_Oct     -0.047990  0.030752 -0.403660 -0.1256421 -4.100e-01
## Oceanic_LK_Nov      0.235450 -0.018878 -0.194963 -0.2189184  3.944e-02
## Oceanic_LK_Dec      0.106917  0.128020  0.142436 -0.0908263 -2.494e-01
# Checking if the PC axes are meaningful
eigenval <- CC.rda1$CA$eig   # Here you will get the eigenvalues
sitecoord <- CC.rda1$CA$u[,1:2]   # The site coordinates along PC1 and PC2
  eig <- data.frame(eigenval)
  eig$nb <- c(1:length(eigenval))
  eig$prop <- eig$eigenval/sum(eig$eigenval)
  eig
# (Kaiser-Guttman)
par(mfrow=c(1,2))
  barplot(eig$eigenval, main="Eigenvalues",las=2)
  abline(h=mean(eig$eigenval),col="red")    # average eigenvalue
  legend("topright","Average eigenvalue",lwd=1,col=2,bty="n")
  
  barplot(100*eig$prop,main="% of variance",las=2)

par(mfrow=c(1,1))

autoplot(CC.rda2, data = PCA.data, colour="Season", 
                shape="Sub_region",
         loadings = TRUE, loadings.colour = 'black',
         loadings.label = TRUE, loadings.label.size = 3,
         loadings.label.vjust = -1.0,
         loadings.label.colour="black",
         frame = TRUE, frame.type = 'norm')+
facet_wrap(~Zone)+MyTheme+Season_colour+Season_fill

autoplot(CC.rda2, data = PCA.data, colour="Zone", 
                shape="Sub_region",
         loadings = TRUE, loadings.colour = 'black',
         loadings.label = TRUE, loadings.label.size = 3,
         loadings.label.vjust = -1.0,
         loadings.label.colour="black",
         frame = TRUE, frame.type = 'norm')+
facet_wrap(~Season)+MyTheme

autoplot(CC.rda2, data = PCA.data, colour="Sub_region", 
                shape="Zone",
         loadings = TRUE, loadings.colour = 'black',
         loadings.label = TRUE, loadings.label.size = 3,
         loadings.label.vjust = -1.0,
         loadings.label.colour="black",
         frame = TRUE, frame.type = 'norm')+
facet_grid(~Season)+MyTheme

autoplot(CC.rda2, data = PCA.data, colour="Season", 
                shape="Zone",
         loadings = TRUE, loadings.colour = 'black',
         loadings.label = TRUE, loadings.label.size = 3,
         loadings.label.vjust = -1.0,
         loadings.label.colour="black",
         frame = TRUE, frame.type = 'norm')+
facet_wrap(~Sub_region)+MyTheme+Season_colour+Season_fill

Packages used

# Creates bibliography 
#knitr::write_bib(c(.packages()), "packages.bib")
Arel-Bundock, Vincent. 2022. Modelsummary: Summary Tables and Plots for Statistical Models and Data: Beautiful, Customizable, and Publication-Ready. https://vincentarelbundock.github.io/modelsummary/.
Arnold, Jeffrey B. 2021. Ggthemes: Extra Themes, Scales and Geoms for Ggplot2. https://github.com/jrnold/ggthemes.
Attali, Dean, and Christopher Baker. 2019. ggExtra: Add Marginal Histograms to Ggplot2, and More Ggplot2 Enhancements. https://github.com/daattali/ggExtra.
Auguie, Baptiste. 2017. gridExtra: Miscellaneous Functions for "Grid" Graphics. https://CRAN.R-project.org/package=gridExtra.
Bates, Douglas, Martin Mächler, Ben Bolker, and Steve Walker. 2015. “Fitting Linear Mixed-Effects Models Using lme4.” Journal of Statistical Software 67 (1): 1–48. https://doi.org/10.18637/jss.v067.i01.
Bates, Douglas, and Martin Maechler. 2021. Matrix: Sparse and Dense Matrix Classes and Methods. http://Matrix.R-forge.R-project.org/.
Bates, Douglas, Martin Maechler, Ben Bolker, and Steven Walker. 2021. Lme4: Linear Mixed-Effects Models Using Eigen and S4. https://github.com/lme4/lme4/.
Cheng, Joe, Bhaskar Karambelkar, and Yihui Xie. 2021. Leaflet: Create Interactive Web Maps with the JavaScript Leaflet Library. https://rstudio.github.io/leaflet/.
Grolemund, Garrett, and Hadley Wickham. 2011. “Dates and Times Made Easy with lubridate.” Journal of Statistical Software 40 (3): 1–25. https://www.jstatsoft.org/v40/i03/.
Henry, Lionel, and Hadley Wickham. 2020. Purrr: Functional Programming Tools. https://CRAN.R-project.org/package=purrr.
J, Lemon. 2006. “Plotrix: A Package in the Red Light District of r.” R-News 6 (4): 8–12.
Kassambara, Alboukadel. 2020. Ggpubr: Ggplot2 Based Publication Ready Plots. https://rpkgs.datanovia.com/ggpubr/.
Kuznetsova, Alexandra, Per B. Brockhoff, and Rune H. B. Christensen. 2017. lmerTest Package: Tests in Linear Mixed Effects Models.” Journal of Statistical Software 82 (13): 1–26. https://doi.org/10.18637/jss.v082.i13.
Kuznetsova, Alexandra, Per Bruun Brockhoff, and Rune Haubo Bojesen Christensen. 2019. lmerTest: Tests in Linear Mixed Effects Models. https://github.com/runehaubo/lmerTestR.
Legendre, Pierre. 2018. Lmodel2: Model II Regression. https://CRAN.R-project.org/package=lmodel2.
Lemon, Jim, Ben Bolker, Sander Oom, Eduardo Klein, Barry Rowlingson, Hadley Wickham, Anupam Tyagi, et al. 2021. Plotrix: Various Plotting Functions. https://CRAN.R-project.org/package=plotrix.
Lenth, Russell V. 2022. Emmeans: Estimated Marginal Means, Aka Least-Squares Means. https://github.com/rvlenth/emmeans.
Müller, Kirill, and Hadley Wickham. 2021. Tibble: Simple Data Frames. https://CRAN.R-project.org/package=tibble.
R Core Team. 2020. R: A Language and Environment for Statistical Computing. Vienna, Austria: R Foundation for Statistical Computing. https://www.R-project.org/.
Robinson, David, Alex Hayes, and Simon Couch. 2022. Broom: Convert Statistical Objects into Tidy Tibbles. https://CRAN.R-project.org/package=broom.
Spinu, Vitalie, Garrett Grolemund, and Hadley Wickham. 2021. Lubridate: Make Dealing with Dates a Little Easier. https://CRAN.R-project.org/package=lubridate.
Wickham, Hadley. 2007. “Reshaping Data with the reshape Package.” Journal of Statistical Software 21 (12): 1–20. http://www.jstatsoft.org/v21/i12/.
———. 2011. “The Split-Apply-Combine Strategy for Data Analysis.” Journal of Statistical Software 40 (1): 1–29. http://www.jstatsoft.org/v40/i01/.
———. 2016. Ggplot2: Elegant Graphics for Data Analysis. Springer-Verlag New York. https://ggplot2.tidyverse.org.
———. 2019. Stringr: Simple, Consistent Wrappers for Common String Operations. https://CRAN.R-project.org/package=stringr.
———. 2020a. Plyr: Tools for Splitting, Applying and Combining Data. https://CRAN.R-project.org/package=plyr.
———. 2020b. Reshape2: Flexibly Reshape Data: A Reboot of the Reshape Package. https://github.com/hadley/reshape.
———. 2021a. Forcats: Tools for Working with Categorical Variables (Factors). https://CRAN.R-project.org/package=forcats.
———. 2021b. Tidyr: Tidy Messy Data. https://CRAN.R-project.org/package=tidyr.
———. 2021c. Tidyverse: Easily Install and Load the Tidyverse. https://CRAN.R-project.org/package=tidyverse.
Wickham, Hadley, Mara Averick, Jennifer Bryan, Winston Chang, Lucy D’Agostino McGowan, Romain François, Garrett Grolemund, et al. 2019. “Welcome to the tidyverse.” Journal of Open Source Software 4 (43): 1686. https://doi.org/10.21105/joss.01686.
Wickham, Hadley, Winston Chang, Lionel Henry, Thomas Lin Pedersen, Kohske Takahashi, Claus Wilke, Kara Woo, Hiroaki Yutani, and Dewey Dunnington. 2021. Ggplot2: Create Elegant Data Visualisations Using the Grammar of Graphics. https://CRAN.R-project.org/package=ggplot2.
Wickham, Hadley, Romain François, Lionel Henry, and Kirill Müller. 2021. Dplyr: A Grammar of Data Manipulation. https://CRAN.R-project.org/package=dplyr.
Wickham, Hadley, and Jim Hester. 2020. Readr: Read Rectangular Text Data. https://CRAN.R-project.org/package=readr.
Xie, Yihui. 2014. “Knitr: A Comprehensive Tool for Reproducible Research in R.” In Implementing Reproducible Computational Research, edited by Victoria Stodden, Friedrich Leisch, and Roger D. Peng. Chapman; Hall/CRC. http://www.crcpress.com/product/isbn/9781466561595.
———. 2015. Dynamic Documents with R and Knitr. 2nd ed. Boca Raton, Florida: Chapman; Hall/CRC. https://yihui.org/knitr/.
———. 2021. Knitr: A General-Purpose Package for Dynamic Report Generation in r. https://yihui.org/knitr/.
Zhu, Hao. 2021. kableExtra: Construct Complex Table with Kable and Pipe Syntax. https://CRAN.R-project.org/package=kableExtra.